I have an automation that unlocks the door when someone arrives home. As a security precaution I would like the door to lock again, if it hasn’t been opened within 3 minutes. I have that working just fine in Node red, but am trying to use the built-in automations instead. What troubles me is the 3 minutes delay, which I have implemented with a “wait for” automation with continue on time out. That works if I do not open the door, then HA waits for 3 minutes and then locks the door again. But if I open the door then the door tries to lock itself immediately. So what I do need is that the automation only continues if “wait for” timeout and if it doesn’t time out (because the door has then been opened) then the automation should stop. Any ideas to accomplish that?
alias: Dørlås - Åben
description: ""
trigger:
- platform: state
entity_id:
- person.morten
from: not_home
to: home
id: morten_hjemme
- platform: state
entity_id:
- person.trine
from: not_home
to: home
id: trine_hjemme
- platform: state
entity_id:
- input_boolean.house_mode
from: "off"
to: "on"
for:
hours: 0
minutes: 0
seconds: 15
condition:
- condition: state
entity_id: lock.danalock
state: locked
action:
- service: lock.unlock
data: {}
target:
entity_id: lock.danalock
- service: notify.all_devices
data:
title: Dørlås
message: Hoveddøren er låst op automatisk
- wait_for_trigger:
- platform: state
entity_id:
- binary_sensor.openclose_12
from: "off"
to: "on"
timeout:
hours: 0
minutes: 3
seconds: 0
milliseconds: 0
continue_on_timeout: true
- service: lock.lock
data: {}
target:
entity_id: lock.danalock
- service: notify.all_devices
data:
message: Hoveddøren er låst igen
title: Dørlås
mode: single
Thanks - the issue I have by putting it in a seperate automation is that I would like to have it triggered by this automation only, not in case we unlock the door ourselves in the morning without opening it. I think I can figure out a work-around where my automation triggers an input boolean and then this one is used in a seperate automation, but it feels a bit like a setback compared to the one flow in Node-Red.
How would the “wait” work - I can’t be absolutely sure that the door will be still be open after exactly 3 minutes, but just during that 3 minutes. But perhaps I misinterpreted the “wait” condition?
Flipping the condition from on to off → off to on will help a bit as the door will then lock once the door is indeed closed again, but often we don’t lock the door when at home, so it will still be a bit inferior to the current implementation in Node Red.