You may wish to review the following post which addresses a similar requirement:
When motion is detected outside a room it proceeds to wait for motion in another location (for up to 2 minutes). Depending on whether this additional motion was detected, a switch is turned on (or not).
In your case, it could set an input_boolean’s state (or not).
Nice. The “idea” of the function works, but not yet perfect. What I’ve got right now is quite what you’ve mentioned
Trigger one is the sensor (1)
then there is a time-out from 30 seconds for the second sensor.
When both sensors are “on”, the input boolean goes to on. ← all fine
The downside is, that the automation waits for the timeout to be completed. So if I was walking down for example, the lights would only go on afther 30 seconds, when the timeout is compelted. But I want to fire that as soon as the second sensor goes on.
Trigger Type: State
Entity: Bedroom Motion Sensor
From: off
To: on
Actions
Action type: Call service
Service: Timer: Start
Target: Bedroom Timer
After 30 seconds the state will change from active to idle
Create a second automation
Name: Lower stairs motion
Trigger Type: State
Entity: Lower Stairs Motion Sensor
From: off
To: on
Conditions
Condition type: State
Entity: Bedroom Timer
State: active
Make sure the timer is running
Actions
Here you can set someone_goes_down to true, turn on lights, stop the timer or whatever, hope it helps. This can be done differently or via just one automation by using trigger ids, just wanted to keep it simple.
@RickTSD
Your automation looks good, but you have to set continue_on_timeout: to false.
With set to true it would always turn the boolean on even the when the zolder_motion sensor remains off.
If wait_for_trigger is triggered within its timeout duration (30 seconds), the variable wait.trigger will have a value.
If wait_for_trigger is not triggered within its timeout duration (30 seconds), the value of wait.trigger will be none.
We can use this information to determine if input_boolean.someone_going_up should be set to on (motion was detected by binary_sensor.shelly_zolder_motion within 30 seconds) or to off (motion was not detected by binary_sensor.shelly_zolder_motion within 30 seconds).
- id: '1650002654833'
alias: Sensors - Someone is going up
description: ''
trigger:
- platform: state
entity_id: binary_sensor.shelly_overloop_motion
from: 'off'
to: 'on'
condition: []
action:
- wait_for_trigger:
- platform: state
entity_id: binary_sensor.shelly_zolder_motion
from: 'off'
to: 'on'
timeout: '00:00:30'
- service: "input_boolean.turn_{{ 'off' if wait.trigger == none else 'on' }}"
target:
entity_id: input_boolean.someone_going_up
mode: single