Get Home Assistant to warn me that door has been open for x minutes on interval

I want an automation that notifies me via Pushbullet and Google Home speaker if my garage door has been open for X number of minutes. I currently have a bunch of individual automations, one that warns me after 5 minutes, another after 15 minutes, 30 minutes and so on. Is there a way to condense all these into one automation that executes every, say, 5 minutes and tells me how many minutes the door has been open? Here is my automation for the 5 minute mark as an example:

- id: '1567746701645'
  alias: ALERT Main Garage Open Longer Than 5 Minutes
  trigger:
  - entity_id: binary_sensor.garage_main
    for: 0:05:00
    platform: state
    to: 'on'
  condition: []
  action:
  - data:
      message: 'SECURITY ALERT: The MAIN GARAGE door has been open for more than five
        minutes on {{now().strftime(''%Y-%m-%d as of %H:%M:%S'')}}.'
    service: notify.mypushbullet
  - data:
      entity_id: media_player.googlehome1575
      message: The garage door has been open for over 5 minutes.
    service: tts.google_translate_say

The alert component does this. The notifiers will probably have to added to a group, but the docs have some examples.

1 Like