How do I delay an automation until I confirm I want it to execute with text

Hi, everyone, I’m really sorry I’m the slow old dude that is trying to learn some new tricks. I’m trying to make my garage door close after being open more than 15 min. I would like to get a text telling me that my garage is going to close. I want a 60 sec delay. I want to stop the closing indefinitely if I respond no, or be able to give a specific time in min to delay the closing. If I do not respond I want the door to close. Is this even possible, will I have to manually restart the automation if I hit no?

Here is the primary automation.

  • id: ‘1692318118861’
    alias: close garage test
    description: ‘’
    trigger:
    • platform: device
      device_id: e483eed7f01b15b7f509c06c4ed0dedd
      domain: cover
      entity_id: 384ef149e9e8702c8c5a6cb2702155ba
      type: opened
      for:
      hours: 0
      minutes: 15
      seconds: 0
      condition: []
      action:
    • service: notify.mobile_app_ez13pro
      data:
      message: Garage is still open.
    • delay:
      hours: 0
      minutes: 1
      seconds: 0
      milliseconds: 0
    • wait_for_trigger: []
    • device_id: e483eed7f01b15b7f509c06c4ed0dedd
      domain: cover
      entity_id: 384ef149e9e8702c8c5a6cb2702155ba
      type: close
      mode: single

secondary:

  • alias: “Handle ‘Do not close’ response”
    trigger:
    platform: event
    event_type: mobile_app_notification_action
    event_data:
    action: “DO_NOT_CLOSE”
    action:

    • service: script.turn_off
      entity_id: script.close_garage_with_delay
  • alias: “Handle delay close response”
    trigger:
    platform: event
    event_type: mobile_app_notification_action
    event_data:
    action: “DELAY_CLOSE”
    action:

    • service: script.turn_off
      entity_id: script.close_garage_with_delay
    • delay:
      minutes: “{{ trigger.event.data.text }}”
    • service: cover.close
      entity_id: cover.your_garage_door

Script:
wanna_close:
alias: Wanna Close
use_blueprint:
path: homeassistant/confirmable_notification.yaml
input:
notify_device: c0e00acb6581f3d71824a255868a4458
title: Delay Close
message: Keep Open?
confirm_action:
- service: cover.open_cover
data: {}
target:
entity_id: cover.garage_door

First, use code tags to preserve your formatting.

I would probably use a helper entity as a condition of the automation.

I’ll give you a brief outline, but first some housekeeping.

Most importantly, you need to format your code as code using the </> button. Indentation is vital in YAML. It’s hard to help if we can’t read your config properly, and it’s difficult to copy and paste to fix it.

The other thing is: refrain from using devices IDs. There are some reasons not that I’m not going to repeat, but you’ll find posts on the topic. Use entity IDs and matching services instead.

Right, so, the best way to do what you want is to break up your automations. One should trigger on the door opening. You’ll start a timer.

Example:

The next automation will be one to trigger when the timer runs out (expires). In there, you can send a push notification to the companion app. Specifically, it can be an actionable notification. You’ll provide an action to close the door. This gets sent as a special event to HA.

Example:

The third automation will trigger on this event and close the door.

Example:

You can do more things like having more actions to extend the timer, or to restart it, or to restart the timer when it had run out as a way get repeated notifications.

Example:

EDIT: Added some examples. I make heavy use of templating, so for a new starter it might take some time to get to terms with it. This was also written 3 years ago, so there might be improvements that could be made too, but it’s been working without any issues.

2 Likes

Ok, sorry about the indent, and thank you for the answer. Fixing now.

Yes, this whole thing has a huge learning curve. However, all of the help that is available makes it seem possible. I’m going to keep plugging away. Once I get to a point where I am lost (which will no doubt be soon) I am going to correctly post the code to get pointed back in the right direction. My wife keeps asking since I’m getting so frustrated, why it matters if I can automate this or not, because it just does, man. It just does. Thanks for understanding.

1 Like