Hello,
I managed to make an automation that turns on my Matter Smart Bulb when my nearby camera detects a person, WIN!
Now I am wondering how I can add an off timer to the automation, so the light goes off after XX minutes from when it was triggered?
I was able to add "Turn Light On" and "Turn Light Off" to the "Then Do" part of the automation setup, but I can't figure out how to put a delay on the OFF action?
Any help on how I might accomplish this would be appreciated.
Thanks!
Use the "time pass" option
There is also a Delay option you can add between in the turn on and turn off.
sequence:
- action: turn_on
- delay:
minutes: XX
- action: turn_off
I found the "wait for time pass to pass" delay option in actions, put that between the "turn on light" and "turn off light" actions and it works perfectly!
Thank you for nudging me in the right direction here!
That is not the best way to do it. Do not wait for extended periods of time in an automation. Instead use a trigger that trips when you have had no motion for x time.
Motion triger for on/off....More logical.
alias: Motion Light
mode: restart
trigger:
- platform: state
entity_id: binary_sensor.Motion_Sensor
to: "on"
action:
- service: light.turn_on
target:
entity_id: light.smart_bulb
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.Motion_Sensor
to: "off"
for:
minutes: 5
- service: light.turn_off
target:
entity_id: light.smart_bulb
Just keep in mind not all motion sensors have ‘turn off’ functionality:
That's exactly what I was talking about. Don't do that. Especially without a timeout.
Do this:
alias: Motion Light On
mode: single
trigger:
- platform: state
entity_id: binary_sensor.Motion_Sensor
to: "on"
action:
- service: light.turn_on
target:
entity_id: light.smart_bulb
alias: Motion Light Off
mode: single
trigger:
- platform: state
entity_id: binary_sensor.Motion_Sensor
to: "off"
for:
minutes: 5
action:
- service: light.turn_off
target:
entity_id: light.smart_bulb
You can combine them into one automation with a choose action if you prefer.