I am configuring an automation to alert me if the garage door left open. I am using the while repeat with the condition if the garage opener device is open for 5 minutes.
The automation trigger with no issue but the wile condition doesn’t stop when I close the garage door. The trace mention unknown status twice then stop.
I don’t know what the “unknown” is all about, but if you close the door after the 10 minute delay has started, you’ll still get the notification. You should remove the first notification (the one before the repeat) and move the other one ahead of the delay.
If you are interested, this is how I would have composed the automation.
The repeat - while uses a wait_template with a timeout instead of a delay. This allows the repeat to terminate immediately when the door is closed (as opposed to waiting for the delay to finish).
- id: '1659482300750'
alias: Garage Door Open
description: ''
trigger:
- platform: state
entity_id: cover.msg100_18f8
from: 'closed'
to: 'open'
for:
minutes: 5
condition: []
action:
- repeat:
while: "{{ is_state('cover.msg100_18f8', 'open') }}"
sequence:
- service: notify.outlook
data:
message: Door left open
title: Garage Door
- wait_template: "{{ is_state('cover.msg100_18f8', 'closed') }}"
timeout: '00:10:00'
mode: single
Thanks, Will give it a try, what I was about to test is something like this but I put another condition to check the state after firing the alert… so it looks like this:
Your latest example still uses a delay so even if the door were to close seconds after the delay begins, the repeat is obligated to wait until the delay finishes counting down the full 5 minutes.
Also, I am not sure why you put the notification after the delay. It’s customary to perform the notification immediately upon entering the repeat then waiting for a period of time to pass before iterating.