Please help me to add a condition that will stop the action when the state changes. My knowledge is too little, and I am hopelessly tinkering over this for the second day. Here is my automation to trigger a buzzer when the door is left open for longer than the time set. How do I make the buzzer go off if the door is closed and not to wait for the action to be fully executed?
alias: Door left open alert
description: Notification if the main door is left open
trigger:
- platform: state
entity_id: binary_sensor.ikea_door_sensor_opening
to: "on"
from: "off"
for: "00:00:10"
id: open
variables:
long_enough: true
- platform: state
entity_id: binary_sensor.ikea_door_sensor_opening
to: "off"
from: "on"
id: closed
variables:
long_enough: "{{ now() - trigger.from_state.last_changed >= timedelta(seconds=10)}}"
condition:
- condition: template
value_template: "{{ long_enough }}"
action:
- repeat:
sequence:
- service: switch.toggle
target:
entity_id: switch.sonoff_100090791d
data: {}
- delay:
hours: 0
minutes: 0
seconds: 2
milliseconds: 0
count: 9
- service: switch.turn_off
target:
entity_id: switch.sonoff_100090791d
data: {}
mode: single
The wait time is set to 10 seconds for testing purposes. The variable long_enough
is added so that the automation does not record every opening.