From 784fead4aa63d599d7f49e6a7da656b307b4ef03 Mon Sep 17 00:00:00 2001 From: "J.P. Krauss" Date: Sun, 8 Sep 2024 17:21:40 -0700 Subject: [PATCH] fix: Fix garage door notification automation --- packages/security/security.yaml | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/packages/security/security.yaml b/packages/security/security.yaml index 2f6aee4..b45e933 100644 --- a/packages/security/security.yaml +++ b/packages/security/security.yaml @@ -643,16 +643,18 @@ automation: condition: "{{ is_state('binary_sensor.garage_door', 'on') }}" mode: restart action: - - alias: Set up variables for the actionable notification + - alias: Set up action variables variables: action_close: "{{ 'CLOSE_' ~ 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 data: - title: Garage Door Open - message: The garage door is open - close it now? + title: Garage Door Left Open + message: > + The garage door is open - close it now? It will automatically + close in 10 minutes. data: actions: - action: "{{ action_close }}" @@ -661,6 +663,8 @@ automation: title: Ignore - alias: Wait for a response + timeout: + minutes: 10 wait_for_trigger: - platform: event event_type: mobile_app_notification_action @@ -668,6 +672,10 @@ automation: # waiting for the specific action avoids accidentally continuing # for another script/automation's notification action action: "{{ action_close }}" + - platform: event + event_type: mobile_app_notification_action + event_data: + action: "{{ action_ignore }}" - alias: Handle the action choose: @@ -676,3 +684,13 @@ automation: - action: switch.turn_on target: 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