Deconz_event automation to dim all 'on' lights

I’m building the automations to use tradfri 5 button remotes as light switches for my kids, using the Deconz Conbee2 stick. I’ve got the one below to work dimming one light, but I’d like one button to work dimming two lights, but only if they’re on. The same goes for another button but for brightness.

How would the data template work if I were to add light.ed_lamp and a condition that the action would only work if the light were already on?

- id: 'ed_main_dimmer_from_switch'
  alias: Ed Main Dimmer From Switch
  initial_state: 'on'
  trigger:
    platform: event
    event_type: deconz_event
    event_data:
      id: ed_switch
      event: 3002
  action:
  - service: light.turn_on
    data_template:
      entity_id: light.ed_main
      brightness: '{% set bri = state_attr(''light.ed_main'', ''brightness'') |
        int %} {{ [bri-30, 0] | max }}'

Wouldn’t that just be a simple state condition?

condition:
  - condition: state
    entity_id: light.ed_lamp
    state: on