Hi,
I am trying to create an actionable notification for my garage door. I want it to trigger when the door is open with an option to close it in the notification. I also want the notification to disappear automatically when the door is closed because the notification and option to close the door is now not needed.
I have a working automation but it only works if I put mode: parallel. I believe this is because once the notification is created, the automation will wait forever at “wait_for_trigger” and wait until the button in the notification is pressed. Simply adding a trigger id in the trigger section to clear the notification (the code is there, but it is disabled in this code example) will trigger a new instance of the automation to run (because mode=parallel) and correctly clear the notification but the original automation will still be stuck at “wait_for_trigger”. To help solve this, I added a second trigger to the “wait_for_trigger” so that it can trigger on the garage door closing. This however does not seem to work.
Can someone help suggest what I need to fix or maybe suggest a way that I do not need to set the mode to parallel. Allowing for parallel runs and enabling the original trigger for closed seems to suggest that it is possible to continually create orphaned automations until we reach 10 (setting this to a higher number would solve the issue but that doesn’t seem like a great idea)
alias: Phone - Door/Garage Notifications
triggers:
- entity_id:
- cover.garage_door_1
to: closed
id: garage_1_closed
trigger: state
enabled: false
- entity_id:
- cover.garage_door_1
to: open
id: garage_1_open
trigger: state
actions:
- choose:
- conditions:
- condition: trigger
id:
- garage_1_closed
sequence:
- data:
message: clear_notification
data:
tag: garage_1_open
action: notify.mobile_app_pixel8_phone
- conditions:
- condition: trigger
id:
- garage_1_open
sequence:
- variables:
action_close_garage_1: "{{ 'CLOSE_GARAGE_DOOR_1' ~ context.id }}"
- action: notify.mobile_app_pixel8_phone
data:
message: Van Garage is Open
data:
tag: garage_1_open
ttl: 0
priority: high
actions:
- action: "{{ action_close_garage_1 }}"
title: Close Garage Door
- wait_for_trigger:
- event_type: mobile_app_notification_action
event_data:
action: "{{ action_close_garage_1 }}"
trigger: event
- trigger: state
entity_id:
- cover.garage_door_1
to: closed
id: garage_1_closed_with_notification_on
- choose:
- conditions:
- condition: template
value_template: >-
{{ wait.trigger.event.data.action == action_close_garage_1
}}
sequence:
- action: cover.close_cover
target:
entity_id: cover.garage_door_1
data: {}
- conditions:
- condition: trigger
id: garage_1_closed_with_notification_on
sequence:
- action: notify.mobile_app_pixel8_phone
metadata: {}
data:
message: clear_notification
data:
tag: garage_1_open
mode: parallel
max: 10