My aim was to create automation that turns on the switch when motion is detected, only if helper schedule is off. It is to reset the timer if new motion is detected within the timeout period. Furthermore, it will not turn the switch on, if manually turned off during the countdown period. It should restart the timeout if motion is detected again before timeout completes. I came up with the following script:
alias: Motion control - test drive
description:
trigger:
- platform: state
entity_id:
- binary_sensor.lumi_motion_sensor_2_motion
to: "on"
- platform: state
entity_id:
- binary_sensor.lumi_motion_sensor_2_motion
from: "on"
to: "off"
for:
hours: 0
minutes: 5
seconds: 0
condition:
- condition: state
entity_id: schedule.nighttime
state: "off"
- condition: state
entity_id: switch.sonoff_1000b3110f
state: "off"
action:
- choose:
- conditions:
- condition: state
entity_id: binary_sensor.lumi_motion_sensor_2_motion
state: "on"
sequence:
- target:
entity_id:
- switch.sonoff_1000b3110f
action: switch.turn_on
data: {}
- wait_for_trigger:
- platform: state
entity_id:
- binary_sensor.lumi_motion_sensor_2_motion
to: "off"
timeout:
hours: 0
minutes: 3
seconds: 0
milliseconds: 0
continue_on_timeout: true
- target:
entity_id:
- switch.sonoff_1000b3110f
action: switch.turn_off
data: {}
- conditions:
- condition: state
entity_id: binary_sensor.lumi_motion_sensor_2_motion
state: "off"
for:
hours: 0
minutes: 4
seconds: 0
sequence:
- target:
entity_id:
- switch.sonoff_1000b3110f
action: switch.turn_off
data: {}
default: []
mode: restart
I have taken into account the cooldown time of the sensor, but even so the countdown does not seem to stop and start again. What have I done wrong? What did I overlook? Are the timeouts in conflict?
Thank you.