Fade down lights before they turn off (like the philips hue app option)

Heya, im looking for a blueprint to link to my motion sensors.

On motion id like the lights to turn on and on a timer fade down to lower light setting before turning OFF. If motion is detected while the lights are faded they should turn back on again.

Ive tried to accomplish this with a handful of automations using input_booleans etc, but its not stable…

Any ideas?

1 Like

If it was me, this is how I would do it -
Automation is triggered by a motion detector, give it an id (eg motion).
Additionally automation is triggered by a:

trigger:
  - platform: event
    event_type: timer.finished
    id: timer_finished
    event_data:
      entity_id: timer.room_fade_lights <----------(create this)

Then in the automation, I use a choose
the first choose has the condition trigger, and then choose motion.
turn the light on at the brightness you want.
cancel the timer (in case it is running - DO NOT FINISH THE TIMER)
start the timer

Add the next choose option - choose trigger again for the condition and then “timer_finished”
Now add a condition that checks that the current brightness level is above the level you want it to fade down to (or use a master input_number slider to set a global value for all the lights you want to have an automation for).
Call the service to decrease the brightness
Start the timer
Make sure the automation is set to restart, not single.

So if motion is detected, the light turns on, the timer is cancelled, and started. The automation ends.
The timer reaches 0, the automation is triggered, the second choose option is executed, the light level is above the set fade level, so it is decreased, the timer is started again and the automation ends. Repeated until the brightness is below the set level.

If you want to turn the light off after this, I would start the timer again, but this time set a duration for however long you want to wait until the light turns off, and then in the default actions block add a call to turn the light off. (It’s probably best to add a duration to all the start timer calls in this automation if they are going to be different lengths).

EDIT:
You should also have a trigger for the light turning off, which you give an id to, and in the choose options you should react to the light turning off, by simply cancelling the timer. This is in case you have turned the light off in the UI or by voice or some other way while the timer is running, because it will turn the light back on again when it is has reached 0.

1 Like

The short answer is to use the transition parameter of light.turn_on / light.turn_off :wink:

It would be completely awesome if this could sonehow be blueprinted…(examines free time over next 3 weeks).

I realise thats not possible as such.

Or is it? :face_with_monocle:

1 Like

the longer answer is that not all lights support the transition parameter, or that they only support it for annoyingly short periods (like all Shelly lights only run transitions up to 5 seconds).