Automation to increase brightness only when a bulb in a light group is on

I created a light group containing all my bulbs in the living room. A Gira wall transmitter is sending deconz event 2001 to HASS. Right now, increasing brightness works fine for all lights in the group light.woonkamer_en_tv_kamer but I would like to just increase brightness for all lights in the group that are on. Right now, lights that are off are turned on which is not exactly what I want. Is there something I could do with a for loop in a template in the automation to make this happen or is there any better solution?

My YAML :

- alias: 'Increase brightness of lamp from dimmer'
  initial_state: 'on'
  trigger:
    platform: event
    event_type: deconz_event
    event_data:
      id: gira_transmitter_woonkamer
      event: 2001
  action:
    - service: light.turn_on
      data_template:
        entity_id: light.woonkamer_en_tv_kamer
        transition: '1'
        brightness: >
          {% set bri = state_attr('light.woonkamer', 'brightness') | int %}
          {{ [bri+50, 249] | min }}
1 Like
1 Like

If your lights are all zigbee based and on Deconz then this works like you want it.