Arrival automation fires twice when two of us get home within a minute Automation
The automation turns on the hall light and disarms the alarm when someone gets home. If my partner and I arrive together, both phones cross the zone boundary within about 40 seconds and the whole thing runs twice, which means the announcement plays twice and the light gets a second command. I have a condition that checks nobody was home, but it clearly evaluates before the first run has finished. What is the correct pattern here?
@cache_invalidator · 7mo ago · 3 replies
Two fixes, and you want both.
First, trigger on the group rather than the people. Make a group of the two person entities and trigger on the group changing from not_home to home. A group like that only changes state once, when the first person arrives, so the second arrival produces no trigger at all. This is the actual fix.
Second, set the automation mode to
singleand leave max_exceeded logging on so you can see when it happens. Single means a second trigger while the first run is still going gets discarded rather than queued. Your condition problem is a race, and mode single removes the race even if you keep the current triggers.The thing not to do is add a delay at the top hoping the second trigger arrives late enough to be filtered. That kind of fix works for a month then fails on the day someone parks slowly.
Reply
Report
@yaml_yeoman · 7mo ago
Group trigger is the right answer. Worth knowing that a person group goes to home if any member is home, so it does exactly what a human means by the house being occupied.
Reply
Report
@logfile_lena · 7mo ago
And put the announcement in its own script called from the automation. Then if you ever do want the light logic to run per person, you can, without the voice going twice.
Reply
Report