When power comes on (light) set brightness

Hi,

Since my lights are not remembering the last brightness setting I would like to set this with a automation as soon as the become available. There is one light in the hallway where we always use the wall switch for turning it on, but it’s always at 100% brightness. Would like to set this to 10%, I don’t mind the light fading from 100% till 10% after turning it on.

So far I have had this:

- alias: 'Set brightness Yun'
  trigger:
    platform: state
    entity_id: light.dimmable_light_6
    scan_interval: 2
    to: 'on'
  action:
    delay: '00:00:2'
    service: light.turn_on
    entity_id: light.dimmable_light_6
    data:
      brightness: 10

But that doesn’t seem to do the trick…

Try this, not sure you need the delay, maybe try with and without:

- alias: 'Set brightness Yun'
  trigger:
    platform: state
    entity_id: light.dimmable_light_6
    to: 'on'
  action:
    - delay: '00:00:02'
    - service: light.turn_on
      data:
        entity_id: light.dimmable_light_6
        brightness_pct: 10

Thanks! Well the power is turned off through the wall switch, after becoming available again I want to automatically set the brightness (of my Zigbee lamp). I just tried your suggestion, doesn’t seem to work.

Ah I see, maybe its not ready in HA for a while, try increasing the delay.

Or add a wait to wait until the light is available

Something like this?

# Wait a total of 5 seconds.
- wait_template: "{{ is_state('light.dimmable_light_5', 'on') }}"
  timeout: 5
  continue_on_timeout: false
- service: light.turn_on
  entity_id: light.dimmable_light_5
  brightness_pct: 10
- wait_for_trigger:
    - platform: state
      entity_id: light.dimmable_light_5
      to: 'on'
      for: 2
  timeout: "{{ wait.remaining }}"
  continue_on_timeout: false
- service: light.turn_off
  entity_id: light.dimmable_light_5

What is the state of the light entity when it is off ? is it unavailable ?