fix: Fix garage door close script
This commit is contained in:
@@ -641,56 +641,67 @@ automation:
|
|||||||
entity_id: alarm_control_panel.ha_alarm
|
entity_id: alarm_control_panel.ha_alarm
|
||||||
to: armed_vacation
|
to: armed_vacation
|
||||||
condition: "{{ is_state('binary_sensor.garage_door', 'on') }}"
|
condition: "{{ is_state('binary_sensor.garage_door', 'on') }}"
|
||||||
mode: restart
|
mode: single
|
||||||
action:
|
action:
|
||||||
- alias: Set up action variables
|
- alias: Set up variables for action callback
|
||||||
variables:
|
variables:
|
||||||
action_close: "{{ 'CLOSE_' ~ context.id }}"
|
|
||||||
action_ignore: "{{ 'IGNORE_' ~ 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
|
action: notify.iphone_jp
|
||||||
data:
|
data:
|
||||||
title: Garage Door Left Open
|
message: "Garage door is open! It will close in 10 minutes if not ignored."
|
||||||
message: >
|
|
||||||
The garage door is open - close it now? It will automatically
|
|
||||||
close in 10 minutes.
|
|
||||||
data:
|
data:
|
||||||
actions:
|
actions:
|
||||||
- action: "{{ action_close }}"
|
|
||||||
title: Close
|
|
||||||
- action: "{{ action_ignore }}"
|
- action: "{{ action_ignore }}"
|
||||||
title: Ignore
|
title: Ignore
|
||||||
|
- action: "{{ action_close }}"
|
||||||
|
title: Close
|
||||||
|
|
||||||
- alias: Wait for a response
|
- alias: Wait for action callback
|
||||||
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
|
||||||
event_data:
|
event_data:
|
||||||
# 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_ignore }}"
|
||||||
- platform: event
|
- platform: event
|
||||||
event_type: mobile_app_notification_action
|
event_type: mobile_app_notification_action
|
||||||
event_data:
|
event_data:
|
||||||
action: "{{ action_ignore }}"
|
action: "{{ action_close }}"
|
||||||
|
timeout:
|
||||||
|
seconds: "30"
|
||||||
|
|
||||||
- alias: Handle the action
|
- alias: Process callback
|
||||||
choose:
|
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 }}"
|
- conditions: "{{ wait.trigger.event.data.action == action_close }}"
|
||||||
sequence:
|
sequence:
|
||||||
- action: switch.turn_on
|
- alias: Close garage door
|
||||||
|
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 }}"
|
- conditions: "{{ not wait.completed }}"
|
||||||
sequence:
|
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:
|
target:
|
||||||
entity_id: switch.garage_door_relay_1
|
entity_id: switch.garage_door_relay_1
|
||||||
|
|||||||
Reference in New Issue
Block a user