Hi. How can I create an automation for if motion 1 is triggered, and then motion 2 is triggered within x seconds of that, then whatever actions occur.
I’m trying to do the standard when motion 1 is triggered “And If” motion 2 is triggered, however I can not figure out a way to have any kind of “within x seconds” criteria doing it this way.
triggers:
- trigger: state
entity_id: binary_sensor.motion_1
from: "off"
to: "on"
actions:
- wait_for_trigger:
- trigger: state
entity_id: binary_sensor.motion_2
from: "off"
to: "on"
timeout:
seconds: x # replace with a number
continue_on_timeout: false
Put the action you want to do after the wait for trigger action.
This way the automation triggers on motion 1. If motion 2 occurs within x seconds then your wanted action is performed. If the wait times out then nothing happens and the automation stops, ready for the next motion 1 event.
The Automation Editor follows its own set of rules for YAML formatting. Basically, it represents values in list format if the given option supports lists.
from supports a list value so the Automation Editor represented the single value off as a list containing one item.
The Automation Editor understands these two examples but will ultimately represent them in YAML list format.