I thought this would work but when my wife and I left home at the same time, the security alarm switch did not turn on. Can anyone tell me why that did not occur?
-Thanks
alias: NFC - Geolocation
description: ""
triggers:
- entity_id:
- person.bernard
- person.karen
trigger: state
actions:
- choose:
- conditions:
- condition: state
entity_id: person.bernard
state: not_home
- condition: state
entity_id: person.karen
state: not_home
sequence:
- target:
entity_id: input_boolean.security_alarm_switch
action: input_boolean.turn_on
- conditions:
- condition: or
conditions:
- condition: state
entity_id: person.bernard
state: home
- condition: state
entity_id: person.karen
state: home
sequence:
- target:
entity_id: input_boolean.security_alarm_switch
action: input_boolean.turn_off
There is no such thing as "at the same time", but if the state change events happen close enough in time (and the mode is set to the default single) then the first person's state would trigger the automation, but the condition would fail because the second person hasn't yet been marked as not_home. Set the mode to queued so that the second person's state change doesn't get dropped.
Another common cause for this type of thing is misunderstanding the state of "not_home". A person entity will have that state when they are not in any active Zone. If you have zones that are contiguous with or overlap "home", your person entity may not be not_home. A better condition would be:
- conditions:
- not:
- condition: state
entity_id: person.karen
state: home
- condition: state
entity_id: person.bernard
state: home
sequence:
To expand on this: if this happened, there will be a warning in the logs. I cannot remember now whether one would see the second trigger with a trace that's aborted or no trace at all, but the logs will definitely tell you.
Thanks I'll have to check the logs the next time, if there is a next time. Didgeridrew's recommendation to change the automation mode to queued sounds like the solution. Now, to get my wife's cell phone for testing. Wish me luck!
Thanks I'll take a look at that. That does seem easier "by the numbers". But I just discovered that I have two Pixel 8 phones, there should only be one. The Pixel 8 was my phone and I got a Pixel 10 Pro and gave the 8 to my wife. It got installed again somehow.
This solves the problem Bernie. You assign device trackers to a person then the system resolves the rest. You can stop worrying about each tracker and just care about the zone. 0== vacant every time.
The zone home count works every time. Testing the state of a person is tricky, because the state of that person can also be the name of a zone. So you'd have to account for states other than home and not_home too.