Check first status before action

Hi All,

I want check first status of light before I do a action.
I have lot of scenes based on Harmony Hub activity. To speedup the light scenes I want check first if a light is on already if so then only change some data (brightness, color) otherwise HA will always send a on status and that is useless…

Cheers,

If you want to change a light’s brightness, color, etc you still need to use the light.turn_on service and specify brightess, color, etc. There are no services like light.set_brightness and light.set_color.

This action sets brightness to 125 (maximum=255) for all lights that are already on.

    action:
    - service: light.turn_on
      data_template: 
        entity_id: >
          {{ states.light | selectattr('state','eq','on') | map(attribute='entity_id') | join(', ') }}
        brightness: 125

To understand how the template works I suggest you copy it into Home Assistant’s Template Editor and experiment with it.

{{ states.light | selectattr('state','eq','on') | map(attribute='entity_id') | join(', ') }}
1 Like

Thank you for the example!