From fc44b3a2c3d623c67022369a9f3da9b8592976bc Mon Sep 17 00:00:00 2001 From: akasma74 Date: Thu, 27 Feb 2020 12:36:43 +0000 Subject: [PATCH] add note on is_state_attr (#12169) * 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 * :pencil2: Tweak Co-authored-by: Franck Nijhof --- source/_docs/configuration/templating.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/_docs/configuration/templating.markdown b/source/_docs/configuration/templating.markdown index 38407aabd138..6668c9d08863 100644 --- a/source/_docs/configuration/templating.markdown +++ b/source/_docs/configuration/templating.markdown @@ -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`.