If you want an interruptible delay…
- alias: Repeat the sequence UNTIL the door is closed
repeat:
sequence:
- alias: This is the delay broke into 2 sec incr so it can be interupted.
repeat:
while: >
{{ expand(door_ent)[0].state == 'on' and repeat.index <= cooldown/2 }}
sequence:
- delay: 00:00:02
- alias: Send announcement message (potentially again)
if: "{{ expand(door_ent)[0].state == 'on' }}"
#Do more stuff here...
until: "{{ expand(door_ent)[0].state == 'off' }}"
Breaks a delay up into 2 second jumps so that when the the target action finishes, there is a very short wait to action.
See all the code here…