Do state changes continue to be monitored after initial trigger?

I would like to be notified if my garage door is left open for over 30 minutes after sundown and before sunrise (during the day if it is left open I don’t care as much).

I created the following automation and it is working mostly as intended:

alias: Garage Door Left Open (for 30 minutes after sunset)
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.garage_door
    for:
      hours: 0
      minutes: 30
      seconds: 0
    to: 'on'
condition:
  - condition: or
    conditions:
      - condition: sun
        after: sunset
      - condition: sun
        before: sunrise
action:
  - service: notify.mobile_app_ej_device
    data:
      message: Garage Door Left Open
      title: Check Garage Door - Left Open
mode: restart

Unfortunately, I’ve noticed if I leave the garage door open starting at like 1pm and forget to close it, and it becomes dark, and it’s still open for longer than 30 minutes, it doesn’t trigger. I had assumed it would be constantly monitoring to see if it was left open for longer than 30 minutes during sundown and sunrise.

Any ideas how to change so it can monitor for this activity even if the “open” event takes place before sundown?

Keyword is here triggering and to be triggered, the state should change. It should change;

  • from x to y
  • from x to something else
  • from something else to y

But if it has not changed, it can’t trigger. Maybe, you can move garage door open trigger into condition and trigger every 10 minutes between sunrise and sunset.

1 Like

It triggers the moment when the binary_sensor’s state changes to on and remains that way for at least 30 minutes. The trigger is now “set” and will “reset” only when the binary_sensor’s state returns to off (i.e. when the door is closed).

The condition accepts the event only if it occurs between sunset and sunrise. So if the door is opened anytime between sunrise and sunset, the condition rejects it.

Knowing all of this, it becomes easy to understand why opening the door before sunset and leaving it open well past sunset will not cause the automation’s trigger to fire.

A quick fix is to simply add a Sun Trigger that fires 30 minutes after sunset (or at sunset; your choice) and a State Condition that checks if the door is open. So if the door was opened before sunset and left open, the automation be triggered a half-hour after sunset, detect the door is open, and notify you.

alias: Garage Door Left Open (for 30 minutes after sunset)
description: ''
trigger:
  - platform: state
    entity_id: binary_sensor.garage_door
    to: 'on'
    for: '00:30:00'
  - platform: sun
    event: sunset
    offset: '00:30:00'
condition:
  - condition: state
    entity_id: binary_sensor.garage_door
    state: 'on'
  - condition: or
    conditions:
      - condition: sun
        after: sunset
      - condition: sun
        before: sunrise
action:
  - service: notify.mobile_app_ej_device
    data:
      message: Garage Door Left Open
      title: Check Garage Door - Left Open
mode: restart

However, if you want to detect, and report, if the door is left open prior to sunset then the question becomes why not just remove the existing condition?

1 Like

Thanks so much for the detailed response - all makes sense now

And to answer your question: my primary concern is having the garage door open for an extended time when it’s dark. I

So if I open before sunset but it’s still open 30 minutes after sunset I would want to know. I had assumed the prior trigger would fire, but your explanation helps me understand why it isn’t…

Thank you!

1 Like

Thank you! I definitely misunderstood the way this trigger would work