feat: Update garage door close script to cancel on disarm

This commit is contained in:
2024-09-21 17:48:12 -07:00
parent 08816f2b9b
commit 22e4607716

View File

@@ -626,7 +626,8 @@ automation:
title: "Doorbell" title: "Doorbell"
message: "Home Doorbell Rang but could not create event: {{ event_data['content']['message'] }}" message: "Home Doorbell Rang but could not create event: {{ event_data['content']['message'] }}"
- alias: Notify that Garage Door is Open - alias: Notify that Garage Door is Open when Alarm Arms
description: Send a Garage Door Open Notice to Phones
trigger: trigger:
- platform: state - platform: state
entity_id: alarm_control_panel.ha_alarm entity_id: alarm_control_panel.ha_alarm
@@ -649,7 +650,7 @@ automation:
action_close: "{{ 'CLOSE_' ~ context.id }}" action_close: "{{ 'CLOSE_' ~ context.id }}"
- alias: Send notice to devices - alias: Send notice to devices
action: notify.iphone_jp action: notify.security
data: data:
message: "Garage door is open! It will close in 10 minutes if not ignored." message: "Garage door is open! It will close in 10 minutes if not ignored."
data: data:
@@ -671,37 +672,47 @@ automation:
event_type: mobile_app_notification_action event_type: mobile_app_notification_action
event_data: event_data:
action: "{{ action_close }}" action: "{{ action_close }}"
- platform: state
entity_id: alarm_control_panel.ha_alarm
to: disarmed
timeout: timeout:
seconds: "30" minutes: "10"
- alias: Process callback - alias: Process callback
choose: choose:
- conditions: "{{ wait.trigger.event.data.action == action_ignore }}" - conditions: "{{ wait.remaining > 0 and wait.trigger.event.data.action == action_ignore }}"
sequence: sequence:
- alias: Notify that the event was ignored - alias: Notify that the event was ignored
action: notify.iphone_jp action: notify.security
data: data:
message: > message: >
{% {%
set person = states.person set person = states.person
|selectattr('attributes.user_id', 'eq', wait.context.user_id) |selectattr('attributes.user_id', 'eq', wait.trigger.event.context.user_id)
|first|default({'attributes':{'friendly_name':'Automation'}}) |first|default({'attributes':{'friendly_name':'Automation'}})
%}Open garage door ignored by {{ person.attributes.friendly_name }} %}Open garage door ignored by {{ person.attributes.friendly_name }}
- conditions: "{{ wait.trigger.event.data.action == action_close }}" - conditions: "{{ wait.remaining > 0 and wait.trigger.event.data.action == action_close }}"
sequence: sequence:
- alias: Close garage door - alias: Close garage door
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.remaining > 0 and wait.trigger.entity_id == 'alarm_control_panel.ha_alarm' }}"
sequence:
- alias: Notify the event was cancelled
action: notify.security
data:
message: "Garage door timeout cancelled because alarm was disarmed"
- conditions: "{{ not wait.completed }}" - conditions: "{{ not wait.completed }}"
sequence: sequence:
- alias: Notify the event timed out
action: notify.iphone_jp
data:
message: "Garage door closing automatically"
- alias: Close garage door - alias: Close garage door
action: switch.turn_on action: switch.turn_on
target: target:
entity_id: switch.garage_door_relay_1 entity_id: switch.garage_door_relay_1
- alias: Notify the event timed out
action: notify.security
data:
message: "Garage door closing automatically"