Hi, could someone please advice me what I am doing wrong, I would like to open my lock when someone comes to home, but to prevent locking and unlocking when someone briefly exit the area I added there condition that the person which entered must be out of the zone for more than 5 mins.
This is my configuration:
alias: Zámek - odemceni
description: ""
trigger:
- platform: zone
entity_id: person.jakub_znamenacek, person.petra_dobesova
zone: zone.home
event: enter
alias: Kdokoli přijde domu
condition:
- condition: not
conditions:
- condition: device
device_id: ac774d802e9175e95c72fcd8928258b5
domain: lock
entity_id: 750b08f8153246abb8d20a30393324d6
type: is_unlocked
alias: Zámek je zamčený
- condition: state
entity_id: trigger.entity_id
state: not_home
for:
hours: 0
minutes: 5
seconds: 0
alias: Ověř, že ten kdo se vrátil byl mimo domov více než 5 min
action:
- service: lock.unlock
data: {}
target:
entity_id: lock.zamek_chodba
- service: notify.all_mobile_devices
data:
title: Automatické odemknutí zámku
message: Došlo k automatickému odemčení zámku vchodových dveří po příchodu domů.
mode: single
You might need a second automation for when someone leaves/enters a zone, your primary trigger is when someone enters the Home zone with conditions that do everything else. Alternatively you could set your trigger to be whenever someone enters or leaves a zone so that the rest of the automation is executed. At the very least you can add an automation to test that entering and exiting the zone for 5 minutes is functional, I know I’ve had hit-and-miss results with realtime zones.
You could also add a condition that waits for 5 minutes to trigger re-entry with commands to execute on failure.
What you propose will cause 5 min delay before the action is executed. I just want to prevent accidental triggeres when I am around my house and I enter and exit the home zone.
alias: Zámek - odemceni
description: ""
trigger:
- platform: zone
entity_id: person.jakub_znamenacek, person.petra_dobesova
zone: zone.home
event: enter
alias: Kdokoli přijde domu
condition:
- condition: not
conditions:
- condition: device
device_id: ac774d802e9175e95c72fcd8928258b5
domain: lock
entity_id: 750b08f8153246abb8d20a30393324d6
type: is_unlocked
alias: Zámek je zamčený
- condition: state
entity_id: "{{trigger.entity_id}}"
state: not_home
for:
hours: 0
minutes: 5
seconds: 0
alias: Ověř, že ten kdo se vrátil byl mimo domov více než 5 min
action:
- service: lock.unlock
data: {}
target:
entity_id: lock.zamek_chodba
- service: notify.all_mobile_devices
data:
title: Automatické odemknutí zámku
message: Došlo k automatickému odemčení zámku vchodových dveří po příchodu domů.
mode: single
but for some reason it does not accept the entity_id: "{{trigger.entity_id}}" it says Entity {{trigger.entity_id}} is neither a valid entity ID nor a valid UUID for dictionary value. They use the trigger.entity_id this way even on offitial HA documentation pages
What you do here is trigger when somebody enters the zone home, and the condition has to be not_home for 5 minutes .
So this would not work in any way.
My suggestion does not cause a 5 minute delay. It triggers on the state not_home set for 5 minutes…
so if you are not_home for 4 minutes, and enter the zone again, it will not trigger.
The screenshot about the trigger entity_id youve took, is in the action field.
The trigger is already a condition, so not useful to use it in your condition again.