Hi, all
I am trying to set up following automation:
After 9pm HA should check every 5 minutes if the Door Lock is “locked”. In case the door is not locked HA waits 3 minutes and then locks the door.
If the lock is left unlocked for at least 3 minutes between 21:00 and 23:59, the following automation will lock it.
alias: Lock Door after 9pm
description: ""
trigger:
- platform: state
entity_id: lock.front_door_lock
from: 'locked'
to: 'unlocked'
for:
minutes: 3
- platform: time
at: '21:00:00'
condition:
- condition: state
entity_id: lock.front_door_lock
state: 'unlocked'
- condition: time
after: "21:00:00"
before: "23:59:00"
weekday:
- sun
- mon
- tue
- wed
- thu
- fri
- sat
action:
- service: lock.lock
target:
entity_id: lock.front_door_lock
mode: single
There’s no need to poll the lock’s state every 5 minutes because the State Trigger is responsible for detecting when the lock is left unlocked for 3 minutes. In other words, between 21:00 and 23:59, no matter how many times you leave the lock unlocked, within 3 minutes the automation will lock it.
EDIT
Correction. Removed line left over from the original automation.
Thank you.
Will give it a try. So far the only issue is with the type: is_locked
Message malformed: extra keys not allowed @ data[‘action’][0][‘target’][‘type’]
I have removed that part and will test it tonight.