I put up two cheap Zigbee motion sensors in my staircase, one at the top and one at the bottom, and a Zigbee light bulb in the ceiling. I have created an automation that turns on the light bulb if motion is detected and then turns off the light if motion is detected again, e.g. if I go downstairs the light turns on and when I am at the bottom the light turns off.
What I’m having problems with is that I want the light to turn off if no second motion is detected within 10 minutes, e.g. if I start going downstairs and go back up instead. Right now the light stays on indefinitely in that case.
Here’s what I’ve done so far (I put a 1 minute delay on the light because the motion sensors have a 1 minute timeout)
alias: Lidl motion test
description: ""
trigger:
- type: motion
platform: device
device_id: aa6b0932cb81fae0c6eb8cbcfa7fe979
entity_id: binary_sensor.lidl_motion_sensor_up_occupancy
domain: binary_sensor
id: motion-up
- type: motion
platform: device
device_id: 1ab4c3c77c28e426fb478d4f44be7a48
entity_id: binary_sensor.lidl_motion_sensor_down_occupancy
domain: binary_sensor
id: motion-down
condition: []
action:
- choose:
- conditions:
- condition: trigger
id: motion-up
- condition: device
type: is_off
device_id: 7ab757b64dc096a28c18b1c790b8f50a
entity_id: light.lidl_light_1
domain: light
sequence:
- type: turn_on
device_id: 7ab757b64dc096a28c18b1c790b8f50a
entity_id: light.lidl_light_1
domain: light
- conditions:
- condition: trigger
id: motion-down
- condition: device
type: is_off
device_id: 7ab757b64dc096a28c18b1c790b8f50a
entity_id: light.lidl_light_1
domain: light
sequence:
- type: turn_on
device_id: 7ab757b64dc096a28c18b1c790b8f50a
entity_id: light.lidl_light_1
domain: light
default: []
- choose:
- conditions:
- condition: trigger
id: motion-up
- condition: device
type: is_on
device_id: 7ab757b64dc096a28c18b1c790b8f50a
entity_id: light.lidl_light_1
domain: light
sequence:
- delay:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
enabled: true
- type: turn_off
device_id: 7ab757b64dc096a28c18b1c790b8f50a
entity_id: light.lidl_light_1
domain: light
- conditions:
- condition: trigger
id: motion-down
- condition: device
type: is_on
device_id: 7ab757b64dc096a28c18b1c790b8f50a
entity_id: light.lidl_light_1
domain: light
sequence:
- delay:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
enabled: true
- type: turn_off
device_id: 7ab757b64dc096a28c18b1c790b8f50a
entity_id: light.lidl_light_1
domain: light
- if:
- condition: device
type: is_on
device_id: 7ab757b64dc096a28c18b1c790b8f50a
entity_id: light.lidl_light_1
domain: light
for:
hours: 0
minutes: 10
seconds: 0
enabled: true
then:
- type: turn_off
device_id: 7ab757b64dc096a28c18b1c790b8f50a
entity_id: light.lidl_light_1
domain: light
enabled: true
mode: single