I have an automation that shows something on a display if it’s music. There are a few words hidden in the attributes to catch and stop the automation, but they do something weird…
Read the documentation, it explicitly mentions that is_state and is_state_attr does not work for comparisons against none.
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') is none or state_attr('sensor.my_sensor', 'attr') == None (note the difference in the capitalization of none in both versions).
Thanks. I read over that part I guess. I have to say that it’s weird that null is also none (None and none apparently; and printed!) but is also ~.
you need to use state_attr('sensor.my_sensor', 'attr') is none or state_attr('sensor.my_sensor', 'attr') == None (note the difference in the capitalization of none in both versions).
I note the difference in capitalisation, but what does it mean? Is there really a difference?
You need different capitalization depending on whether your comparison operator is is or ==. Why? Can’t say I’m technical enough to understand or explain that, but I think it has something to do with which “layer” does the comparison. Capitalized None is Python while lowercase none happens in Jinja? Or something like that…