feat: Add front door unlocked on arming automation

This commit is contained in:
2024-09-21 17:58:54 -07:00
parent 22e4607716
commit d32dfcebcb

View File

@@ -716,3 +716,94 @@ automation:
action: notify.security action: notify.security
data: data:
message: "Garage door closing automatically" message: "Garage door closing automatically"
- alias: Notify that Front Door is Unlocked when Alarm Arms
description: Send a Front Door Unlocked Notice to Phones
trigger:
- platform: state
entity_id: alarm_control_panel.ha_alarm
to: armed_home
- platform: state
entity_id: alarm_control_panel.ha_alarm
to: armed_away
- platform: state
entity_id: alarm_control_panel.ha_alarm
to: armed_night
- platform: state
entity_id: alarm_control_panel.ha_alarm
to: armed_vacation
condition: "{{ is_state('lock.front_door_lock_doorlock', 'unlocked') }}"
mode: single
action:
- alias: Set up variables for action callback
variables:
action_ignore: "{{ 'IGNORE_' ~ context.id }}"
action_lock: "{{ 'LOCK_' ~ context.id }}"
- alias: Send notice to devices
action: notify.security
data:
message: "Front door is unlocked! It will lock in 10 minutes if not ignored."
data:
actions:
- action: "{{ action_ignore }}"
title: Ignore
- action: "{{ action_lock }}"
title: Lock
- 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_ignore }}"
- platform: event
event_type: mobile_app_notification_action
event_data:
action: "{{ action_lock }}"
- platform: state
entity_id: alarm_control_panel.ha_alarm
to: disarmed
timeout:
minutes: "10"
- alias: Process callback
choose:
- conditions: "{{ wait.remaining > 0 and wait.trigger.event.data.action == action_ignore }}"
sequence:
- alias: Notify that the event was ignored
action: notify.security
data:
message: >
{%
set person = states.person
|selectattr('attributes.user_id', 'eq', wait.trigger.event.context.user_id)
|first|default({'attributes':{'friendly_name':'Automation'}})
%}Unlocked front door ignored by {{ person.attributes.friendly_name }}
- conditions: "{{ wait.remaining > 0 and wait.trigger.event.data.action == action_lock }}"
sequence:
- alias: Lock front door
action: lock.lock
target:
entity_id: lock.front_door_lock_doorlock
- 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: "Front door timeout cancelled because alarm was disarmed"
- conditions: "{{ not wait.completed }}"
sequence:
- alias: Lock front door
action: lock.lock
target:
entity_id: lock.front_door_lock_doorlock
- alias: Notify the event timed out
action: notify.security
data:
message: "Front door locking automatically"