So I created an automation based on a specific event that waits for 30 seconds, and then turns a light on and then off. However, during that initial 30 seconds, if it sees a different event, then I basically want it to cancel the automation. What’s the best way to do that?
Have the first automation turn on the light and start a timer. When the timer finishes, a 2nd automation turns off the light. Add a 3rd automation for your different event that cancels the timer. I use this method for motion activated lights where manually activating the light cancels the motion timeout.
There is no “best way” but you have plenty of options.
I’d say:
- create your automation as described (
trigger: event
) with action: likedelay: 30
,light.turn_on
,turn_off
etc.
Beforedelay
setinput_boolean
toon
and after add a condition so your actions continues only if theinput_boolean
is stillon
. set it tooff
then. - create an automation with
trigger: even
that cancels the first automation. inaction
just set thatinput_boolean
tooff
.
You might get something better using wait_template
but I’m not sure…
I think this is close, but not exactly what was asked for (i.e., cancel if a different event happens during the initial 30 seconds.)
So, building on what @AaronCake suggested…
One automation watches for the event and when triggered starts a 30 second timer. A second automation watches for the other event and if triggered cancels the timer. A third automation that turns the light on, waits and turns it off, which is triggered by the timer finishing. (Note that this third automation will not trigger on the timer being cancelled, only if it finishes normally.)
Thanks guys. I think with these it should be easy to put something together. I just couldn’t wrap my head around it before.