Notify when state has not changed, garage door left open

Hi i am trying to make an automation which triggers if the garage door is left open. I can’t use the proximity of persons because not everybody carries his/her phone all the time. I want to receive a notification when the door is left open for 5 minutes and after that every X minutes a reminder that it still is open… At the moment i’m thinking of making a time based automation which checks the state every X minutes and when it is still open it sends the notification. But… this feels as “polling” and the automation is invoked way to often. Is there a smarter way to do this?

Try this

alias: Garage Door Left Open Reminder
trigger:
  - platform: state
    entity_id: binary_sensor.garage_door
    to: "on"
    for: "00:05:00"  # Wait 5 minutes before triggering
action:
  - service: notify.mobile_app_mobil
    data:
      message: "Garage door is still open!"
  - repeat:
      while:
        - condition: state
          entity_id: binary_sensor.garage_door
          state: "on"
      sequence:
        - delay: "00:10:00"  # Change to X minutes for reminders
        - service: notify.mobile_app_rmobil
          data:
            message: "Reminder: The garage door is still open!"
mode: restart

Thanks, perfect. i made a small change because waiting 10 minutes before sending the notification after the condition has been met is to late. The door could have been shut by this time.

My order is:

  • notify
  • repeat until closed
    • wait X (or Y)
    • notify again

Wouldn’t it be better to trigger on time- every five minutes- then test the sensor status in condition?

Is a timer-based-triggertm better then a delay()tm :thinking: ?

There is no “better”. It depends on what you want to happen.

The state trigger only triggers when the entity state changes. When the door state changes to open for five minutes you will trigger the automation. It will never trigger again until the state changes to closed then to open again. In other words, once. And only once.

The time trigger will trigger periodically, like every five minutes. The automation can then check the state condition. If the door is open, trigger the automation. In other words, as long as the door is open you will get repeated messages until it is closed.

Using delays, especially longer ones, aren’t robust against HA restarts. Use timers instead which are restored upon a restart.

Also have a look at the built-in alert integration.

There’s also this powerful custom integration.