Automatization for door

I have a specific need that I’ve been trying to accomplish with mixed results. I need to get a message when my front door is opened for more than 3 minutes. Also, I want this message to continue every 3 minutes until the door is closed. I would also like that the first message is sent as soon as the 3 minutes of the opened door is reached.

Right now my automation fires without waiting the 3 minutes, but the repeat every 3 minutes works just fine. So at this point, if I open my door for any duration (even less than 3 minutes) I will get the first message 3 minutes after and I will continue to get the message until the door is closed.

Problems I have:

  1. The for: in the trigger is not working for some reason as it fires without waiting.
  2. I get the first message after the delay in the repeat action. I only want message #2 and every other one every 3 minutes.

This is my automation:

  alias: DOOR_OPEN
  description: Door open for more than 2 minutes
  trigger:
  - platform: state
    entity_id: binary_sensor.main_door
    from: 'off'
    to: 'on'
    for: 00:03:00
  condition: []
  action:
  - repeat:
      until:
      - condition: state
        entity_id: binary_sensor.main_door
        state: 'off'
      sequence:
      - delay: 00:03:00
      - service: notify.pushbullet
        data:
          message: Main door opened!,
          target:
          - email/[email protected]
  mode: single

Thank you!

I suspect you’re misinterpreting what is really happening. That said, you shouldn’t need to create this functionality. It already exists in the alert integration.

But, if you really want or need to do this as an automation, try this:

  alias: DOOR_OPEN
  description: Door open for more than 2 minutes
  trigger:
  - platform: state
    entity_id: binary_sensor.main_door
    to: 'on'
    for: 00:03:00
  condition: []
  action:
  - repeat:
      while:
      - condition: state
        entity_id: binary_sensor.main_door
        state: 'on'
      sequence:
      - service: notify.pushbullet
        data:
          message: Main door opened!,
          target:
          - email/[email protected]
      - wait_template: "{{ is_state('binary_sensor.main_door', 'off') }}"
        timeout: 00:03:00
  mode: single

You’re awesome Phil. Thank you. I didn’t know about the alerts, and it’s exactly what I need. Thanks again.
Leo