fix: Fix garage door notification automation

This commit is contained in:
2024-09-08 17:21:40 -07:00
parent 16c63ee7c1
commit 784fead4aa

View File

@@ -643,16 +643,18 @@ automation:
condition: "{{ is_state('binary_sensor.garage_door', 'on') }}" condition: "{{ is_state('binary_sensor.garage_door', 'on') }}"
mode: restart mode: restart
action: action:
- alias: Set up variables for the actionable notification - alias: Set up action variables
variables: variables:
action_close: "{{ 'CLOSE_' ~ context.id }}" action_close: "{{ 'CLOSE_' ~ context.id }}"
action_ignore: "{{ 'IGNORE_' ~ context.id }}" action_ignore: "{{ 'IGNORE_' ~ context.id }}"
- alias: Ask to close the Garage Door - alias: Send the notification with Close/Ignore actions
action: notify.iphone_jp action: notify.iphone_jp
data: data:
title: Garage Door Open title: Garage Door Left Open
message: The garage door is open - close it now? message: >
The garage door is open - close it now? It will automatically
close in 10 minutes.
data: data:
actions: actions:
- action: "{{ action_close }}" - action: "{{ action_close }}"
@@ -661,6 +663,8 @@ automation:
title: Ignore title: Ignore
- alias: Wait for a response - alias: Wait for a response
timeout:
minutes: 10
wait_for_trigger: wait_for_trigger:
- platform: event - platform: event
event_type: mobile_app_notification_action event_type: mobile_app_notification_action
@@ -668,6 +672,10 @@ automation:
# waiting for the specific action avoids accidentally continuing # waiting for the specific action avoids accidentally continuing
# for another script/automation's notification action # for another script/automation's notification action
action: "{{ action_close }}" action: "{{ action_close }}"
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_ignore }}"
- alias: Handle the action - alias: Handle the action
choose: choose:
@@ -676,3 +684,13 @@ automation:
- action: switch.turn_on - action: switch.turn_on
target: target:
entity_id: switch.garage_door_relay_1 entity_id: switch.garage_door_relay_1
- conditions: "{{ wait.trigger.event.data.action == action_ignore }}"
sequence: []
# no-op
- conditions: "{{ not wait.completed }}"
sequence:
- action: switch.turn_on
target:
entity_id: switch.garage_door_relay_1