Currently it is complicated to distinguish between whether an attribute doesn’t exist or it does exist but is equal to None
.
Docs suggeset that testing for None
should be done by either of these two methods:
state_attr('sensor.my_sensor', 'attr') is none
state_attr('sensor.my_sensor', 'attr') == None
But those will both also yield True
if the attribute is not defined.
is_state_attr('sensor.my_sensor', 'attr', None)
will return False
in every scenario, so is not helpful.
The only viable method is to obtain the state object, and then these two options are possible:
states.sensor.my_sensor.attributes.attr == None
states.sensor.my_sensor.attributes.attr is defined and state_attr(my_sensor, 'attr') == None
But both require obtaining the state object first.
WTH isn’t there a test, filter, or function we can use on an entity_id
?