I want to turn on a light if “detector 1” detects motion and then followed by “detector 2” detects motion.
I only want to turn on the light if the detectors detect in this order. I assume the solution will be simple enough, but I couldn’t figure out how to do it🙃.
For added functionality, it would be great if the light is turned only if detector 2 starts motion detection within 10 seconds of detector 1 starting motion detection. Hope I’ve made some sense here 🫠.
Hi, this is an example of such an automation with a “wait for trigger”.
If within 20secs after motion in the hall there is motion in the office, only then the light goes on. (in a dimmed state)
Does your automation work as intended? This is exactly what I want to do too.
Can you explain how the wait for trigger works.
So I made an automation using your code, and for the action I selected wait for trigger of the second motion sensor. Then I also added the turn on light in the action.
But how can this work? It waits for a trigger as a action and while also turning the light on…
The actions in the actions section of an automation are carried out in sequence. So, if you have a Wait for Trigger action followed by a Call Service (turn on light) action then, the light will not be turned on until the Wait for Trigger action has received it’s trigger event.
There are also options to specify what to do if the trigger doesn’t occur in a given time period.
OK got it. Thanks
The sequential is whete I was confused as usually the actions are run all at once.
So what is the timeout. Is it how long the wait for trigger waits for until the 2nd motion sensor triggers. And if the time elapses, then the automation stops?
Amd also what is the “continue in timeout” checkbox
They may look like they all run at once because, in most cases, the actions being performed are almost instantanious but, they actually always run in sequence.
Firstly, if no timeout time is set then HA will wait forever for the trigger event to occur. The subsequent actions in the actions section may never get executed.
If a timeout time is specified then HA will do somrthing when either the trigger event being awaited occurs or the timeout time elapses.
Then, either:
If the trigger event being awaited occurs before the timeout time elapses then the next action in the sequesnce of acions will be executed.
If the timout elapses before the trigger event awaited occurs then what happens depends on the setting of the Continue on Timeout toggle.
If the toggle is off (so don’t continue) then the sequence of actions will stop - no more actions in the sequence will be executed.
If, on the other hand, the Continue on Timeout toggle in on then processing will continue through the remaining actions in the sequence.
Also, if HA is reastarted or the automation is reloaded then the automation will be aborted. This will most likely mean that the automation will stop waiting for a trigger and stop entirely.
No, I think it’s because you didn’t put your question in any category.
You can still change this by editing your first post (the title) and then mark as solved.