My scripts has stopped working so I believe that the attribute used to return 0 instead of disappearing when turned off.
I used to have the following in my script:
- condition: template
value_template: "{{ state_attr('light.sovrum_vagg','brightness') | int < 225}}"
I am not sure when it stopped working, but now I had to add a check for when brightness is none in order to get it to work again:
- condition: template
value_template: "{{ state_attr('light.sovrum_vagg','brightness') == none or state_attr('light.sovrum_vagg','brightness') | int < 225}}"
These are the attributes that are returned when the light is DIMMED:
{{ states[‘light.sovrum_vagg’].attributes }} =>
{'supported_color_modes': [<ColorMode.BRIGHTNESS: 'brightness'>], 'color_mode': <ColorMode.BRIGHTNESS: 'brightness'>, 'brightness': 153, 'entity_id': ['light.sovrum_dimmer_d23'], 'icon': 'mdi:lightbulb', 'friendly_name': 'Sovrum Vägg', 'supported_features': 0}
These are the attributes that are returned when the light is TURNED OFF - it is missing the brightness attribute, which really should be set to zero here:
{{ states[‘light.sovrum_vagg’].attributes }} =>
{'supported_color_modes': [<ColorMode.BRIGHTNESS: 'brightness'>], 'entity_id': ['light.sovrum_dimmer_d23'], 'icon': 'mdi:lightbulb', 'friendly_name': 'Sovrum Vägg', 'supported_features': 0}
So I think this is to be considered as a bug. The brightness attribute for the dimmed light must be possible to set to 'brightness': 0
when the brightness value is zero.
Also it is stated in the documentation that the brightness is supposed to be 0 when the light is turned off.