I tried to set up an automation of my stairwell with 4 motion sensors and 3 lights.
What I expected:
Lights turn on when motion on any of the motion sensors is detected and light switches off after there is no motion for 30 seconds on all motion sensors.
What actually happens:
Lights turn on when motion is detected and turn off instantly, like on and off in one second. When I look into my automation’s log I can see the “wait” action is triggered after 30 seconds but at that point lights are already off.
How I did it:
I grouped the motion sensors in an HA binary group and made sure they’re not on “and” but “or”. Now I use them as a trigger to turn on the lights. After a short period of time the lights should turn off again. I tried to do that with a “wait for trigger” action. This is my YAML so far:
alias: "Stairwell light automation"
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.stairwell_motion_sensors
from: "off"
for:
hours: 0
minutes: 0
seconds: 0
id: Motion detected
to: "on"
alias: Motion sensor detects motion
condition: []
action:
- service: light.turn_on
data: {}
target:
entity_id: light.stairwell_lights
- wait_for_trigger:
- platform: state
entity_id:
- binary_sensor.stairwell_1st_floor_occupancy
from: "on"
to: "off"
for:
hours: 0
minutes: 0
seconds: 30
timeout:
hours: 0
minutes: 0
seconds: 0
milliseconds: 0
- service: light.turn_off
data: {}
enabled: true
target:
entity_id: light.stairwell_lights
mode: restart
In the last part I switched out the binary group with the exact motion sensor I’m experimenting with because I realized ALL of the motion sensors shouldn’t have detected motion for 30 seconds.