Attempting to automate the locking of the back door. a) I’m lazy that way b) Spouse is forgetful
Worked it out in the Developer Tools template editor, plopped that into an automation, and (of course!) the automation does not fire. I presume I’ve overlooked something rather simple. The desired behavior is this: If the door is closed (alarm sensor value) and the lock is unlocked (lock device value) for more than X minutes, then lock the lock.
Here’s the code:
- id: '12345678'
alias: Sunroom Door - Lock after XX minutes
description: ''
trigger:
- platform: state
entity_id: binary_sensor.sunroom_door
to: closed
for:
hours: 0
minutes: 2
seconds: 0
milliseconds: 0
condition:
- condition: template
value_template: "{{ states('binary_sensor.sunroom_door') == 'off' and states('lock.sunroom_door_lock') == 'unlocked' }}"
action:
- service: lock.lock
target:
entity_id:
- lock.sunroom_door_lock
mode: single