Skip to content

Commit

Permalink
add note on is_state_attr (home-assistant#12169)
Browse files Browse the repository at this point in the history
* add note on is_state_attr

Added a note about is_state_attr when attribute's value is None.
Based on https://community.home-assistant.io/t/can-someone-please-explain/128041 and https://community.home-assistant.io/t/is-state-attr-with-none-argument-to-test/173723

* ✏️ Tweak

Co-authored-by: Franck Nijhof <[email protected]>
  • Loading branch information
akasma74 and frenck authored Feb 27, 2020
1 parent 7a9f3d2 commit fc44b3a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion source/_docs/configuration/templating.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ Extensions allow templates to access all of the Home Assistant specific states a
- `states('device_tracker.paulus')` will return the state string (not the object) of the given entity or `unknown` if it doesn't exist.
- `is_state('device_tracker.paulus', 'home')` will test if the given entity is the specified state.
- `state_attr('device_tracker.paulus', 'battery')` will return the value of the attribute or None if it doesn't exist.
- `is_state_attr('device_tracker.paulus', 'battery', 40)` will test if the given entity attribute is the specified state (in this case, a numeric value).
- `is_state_attr('device_tracker.paulus', 'battery', 40)` will test if the given entity attribute is the specified state (in this case, a numeric value). Note that the attribute can be `None` and you want to check if it is `None`, you need to use `state_attr('sensor.my_sensor', 'attr') == None`.

<div class='note warning'>

Expand Down

0 comments on commit fc44b3a

Please sign in to comment.