Individual brightness in automation

Hi,
How do I set individual brightness on the lights in the automation config below?

- alias: 'Sun down'
  trigger:
    platform: state
    entity_id: input_boolean.1
    from: 'off'
    to: 'on'
  condition:
    condition: state
    entity_id: sun.sun
    state: 'below_horizon'    
  action:
    - service: homeassistant.turn_on
      entity_id: 
        - switch.albins_rum__fonster
        - switch.kontor__fonster
        - switch.vardagsrum__bokhylla
    - service: light.turn_on
      entity_id: 
        - light.kok__fonster
        - light.vardagsrum__fonster
        - light.hall__vagglampa
        - light.sovrum__fonster      
        - light.hall__vagglampa
    - service: homeassistant.turn_off
      entity_id: 
        - switch.albins_rum__hylla
        - switch.kok__lilla_fonstret
        - switch.kontor__hylla
        - switch.vardagsrum__tvbank
        - switch.sovrum__hoger
        - switch.sovrum__vanster
    - service: light.turn_on
      entity_id: 
        - light.kontor__skrivbord
        - light.vardagsrum__lampa
        - light.hall__vagglampa
        - light.vardagsrum__snehylla
        - light.vardagsrum__snehylla

light.turn_on accepts “brightness” as a data parameter

    - service: light.turn_on
      entity_id: kok__fonster
      data:
        brightness: 127

Brightness is on a scale from 0 to 255.

1 Like

Thanks! Can I do that on all light as they are now or do I need to set one by one up as service?

You can add brightness to each light.turn_on if you’re setting a group of lights to the same brightness. Otherwise, you’ll need a separate light.turn_on service for each.

Thanks for your quick reply, now I got it to work!