I have 4 automations set up on my front door, which has a binary sensor attached (“binary_sensor.alarm_panel_pro_001fd8_zone_1”):
- If the door is left open for >5 minutes. Set a helper input_boolean “front door left open” to true, and send a push notification to my phone to tell me the door is left open
- If the door is left open >1 hour, send an urgent notification to my phone
- If the door is closed, turn off “front door left open”
- Once the door is eventually closed (i.e. when “front door left open” is turned off, in either of cases 1 or 2), send a push notification to my phone that the door has finally been closed.
The working Yaml for these is below (copy/pasted from automations.yaml, although I set these up in the GUI) - perhaps this is useful to others who want something similar.
However, as a programmer I find it a bit cumbersome (and likely fragile to future changes) to have 4 different automations tangled together in this way to control one coherent set of actions related to the front door.
Is there a better way to do this kind of thing? Whether built into HA or via an integration/a different mechanism to create automations that is more unified?
thx, Vince.
- id: '1700407367739'
alias: 'Front Door: Notify if left open too long'
description: ''
trigger:
- platform: state
entity_id:
- binary_sensor.alarm_panel_pro_001fd8_zone_1
from: 'off'
to: 'on'
for:
hours: 0
minutes: 5
seconds: 0
condition: []
action:
- service: notify.mobile_app_vinces_iphone
data:
message: Front door has been open for 5 minutes
- service: input_boolean.turn_on
metadata: {}
data: {}
target:
entity_id: input_boolean.front_door_left_open
mode: single
- id: '1700407839774'
alias: 'Front Door: Notify if open for an hour'
description: ''
trigger:
- platform: state
entity_id:
- binary_sensor.alarm_panel_pro_001fd8_zone_1
from: 'off'
to: 'on'
for:
hours: 1
minutes: 0
seconds: 0
condition: []
action:
- service: notify.mobile_app_vinces_iphone
data:
message: 'URGENT: Front door open for an hour'
mode: single
- id: '1715166779470'
alias: 'Front Door: Closing'
description: ''
trigger:
- platform: state
entity_id:
- binary_sensor.alarm_panel_pro_001fd8_zone_1
from: 'on'
to: 'off'
for:
hours: 0
minutes: 0
seconds: 0
condition: []
action:
- service: input_boolean.turn_off
metadata: {}
data: {}
target:
entity_id: input_boolean.front_door_left_open
mode: single
- id: '1715166572466'
alias: 'Front Door: Eventually Closed'
description: ''
trigger:
- platform: state
entity_id:
- input_boolean.front_door_left_open
from: 'on'
to: 'off'
condition: []
action:
- service: notify.mobile_app_vinces_iphone
metadata: {}
data:
message: Front door is now closed
mode: single
(thank you - post formatted correctly now)