Rework door open alerts, close #185

This commit is contained in:
2024-01-02 17:56:40 -05:00
parent f0e35bff08
commit b646616047
3 changed files with 114 additions and 23 deletions

View File

@ -4417,3 +4417,103 @@
alias: Call tylenol script
mode: parallel
max: 10
- id: '1704233489587'
alias: Door Open Alert
description: ''
trigger:
- alias: Front door open
platform: state
entity_id:
- binary_sensor.front_door
from: 'off'
to: 'on'
for:
hours: 0
minutes: 0
seconds: 0
id: front_door
- alias: Back door open
platform: state
entity_id:
- binary_sensor.back_door
from: 'off'
to: 'on'
for:
hours: 0
minutes: 0
seconds: 0
id: back_door
condition: []
action:
- variables:
sensor: '{{ "binary_sensor." + trigger.id }}'
alias: Set entity ID for the repeat loop
- alias: Repeat loop while triggered door is open
repeat:
sequence:
- alias: Decide announcements and light alerts
if:
- condition: template
value_template: '{{ repeat.first == ''true'' }}'
alias: If this is the first repeat
then:
- alias: Wait 2 minutes, break out if door is closed
wait_for_trigger:
- platform: template
value_template: '{{ is_state(sensor,''off'') }}'
alias: Triggered door closed
timeout:
hours: 0
minutes: 2
seconds: 0
milliseconds: 0
else:
- parallel:
- if:
- condition: template
value_template: '{{ repeat.index > 2 }}'
alias: If this is the third or higher repeat
then:
- parallel:
- alias: Living Room Lights Alert
service: script.living_room_lights_alert
data:
duration: 10
type: red
flash: true
- service: script.basement_lights_alert
data:
type: red
duration: 10
flash: true
alias: Basement Lights Alert
alias: Light alerts
alias: Light alert starts at 3rd repeat
- service: script.status_annc
data:
who: living_room
call_interruption: 1
call_snark_door_open: 1
alias: Play announcement
alias: Run announcement and, if applicable, light alerts
- alias: Wait 2 minutes, break out if door is closed
wait_for_trigger:
- platform: template
value_template: '{{ is_state(sensor,''off'') }}'
alias: Triggered door closed
timeout:
hours: 0
minutes: 1
seconds: 50
milliseconds: 0
while:
- alias: Triggered door is open
condition: template
value_template: '{{ is_state(sensor,''on'') }}'
- alias: Play announcement
service: script.status_annc
data:
who: living_room
call_snark_door_closed: 1
mode: parallel
max: 5

View File

@ -42,25 +42,4 @@ alert:
- tv_notifications
- ios_tony
- ios_tina
- ios_kallen
automation:
- id: 5a82b718-3846-452b-9aa4-a183a88c8f29
alias: Door Open Alert
trigger:
- platform: state
entity_id:
- binary_sensor.front_door
- binary_sensor.back_door
from: 'off'
to: 'on'
for:
hours: 0
minutes: 2
seconds: 0
action:
- service: script.status_annc
data:
who: 'living_room'
call_interruption: 1
call_snark_door_open: 1
- ios_kallen

View File

@ -1759,7 +1759,15 @@ script:
'Can a human be so kind and close it?',
'The air quality in this house has actually improved.',
'Closing the door would improve the security of the house.',
'Hey. The door was just opened and this is crazy. But now you know. So. Close it maybe.'
'Hey. The door was just opened and this is crazy. But now you know. So close it maybe.'
] | random }}
{%- endmacro -%}
{%- macro snark_door_closed() -%}
{{ [
'Thank you for finally closing the door. The outside world is grateful.',
'The door has been closed. Thank you for paying attention.',
'You have closed the door. Nerd Home Incorporated thanks you for singlehandedly saving the planet.',
] | random }}
{%- endmacro -%}
@ -1919,6 +1927,10 @@ script:
{{ snark_door_open() }}
{% endif %}
{% if call_snark_door_closed == 1 %}
{{ snark_door_closed () }}
{% endif %}
{% if call_school_pickup_reminder == 1 %}
{{ school_pickup_reminder() }}
{% endif %}