fix: Fix garage door close script

This commit is contained in:
2024-09-21 17:10:59 -07:00
parent 784fead4aa
commit 08816f2b9b

View File

@@ -641,56 +641,67 @@ automation:
entity_id: alarm_control_panel.ha_alarm
to: armed_vacation
condition: "{{ is_state('binary_sensor.garage_door', 'on') }}"
mode: restart
mode: single
action:
- alias: Set up action variables
- alias: Set up variables for action callback
variables:
action_close: "{{ 'CLOSE_' ~ context.id }}"
action_ignore: "{{ 'IGNORE_' ~ context.id }}"
action_close: "{{ 'CLOSE_' ~ context.id }}"
- alias: Send the notification with Close/Ignore actions
- alias: Send notice to devices
action: notify.iphone_jp
data:
title: Garage Door Left Open
message: >
The garage door is open - close it now? It will automatically
close in 10 minutes.
message: "Garage door is open! It will close in 10 minutes if not ignored."
data:
actions:
- action: "{{ action_close }}"
title: Close
- action: "{{ action_ignore }}"
title: Ignore
- action: "{{ action_close }}"
title: Close
- alias: Wait for a response
timeout:
minutes: 10
- alias: Wait for action callback
wait_for_trigger:
- platform: event
event_type: mobile_app_notification_action
event_data:
# waiting for the specific action avoids accidentally continuing
# for another script/automation's notification action
action: "{{ action_close }}"
action: "{{ action_ignore }}"
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_ignore }}"
action: "{{ action_close }}"
timeout:
seconds: "30"
- alias: Handle the action
- alias: Process callback
choose:
- conditions: "{{ wait.trigger.event.data.action == action_ignore }}"
sequence:
- alias: Notify that the event was ignored
action: notify.iphone_jp
data:
message: >
{%
set person = states.person
|selectattr('attributes.user_id', 'eq', wait.context.user_id)
|first|default({'attributes':{'friendly_name':'Automation'}})
%}Open garage door ignored by {{ person.attributes.friendly_name }}
- conditions: "{{ wait.trigger.event.data.action == action_close }}"
sequence:
- action: switch.turn_on
- alias: Close garage door
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
- alias: Notify the event timed out
action: notify.iphone_jp
data:
message: "Garage door closing automatically"
- alias: Close garage door
action: switch.turn_on
target:
entity_id: switch.garage_door_relay_1