Added HA to another mobile device in the home and (even thought I saw it coming and attempted to pre-empt it with the clever use of a helper) it’s naturally broken our if Home = 0 then do stuff automations because one of the devices stays here because it’s attached to a teenager.
Created a binary presence sensor called adult_phones:
{{ is_state('device_tracker.name1_iphone', 'home') and is_state('device_tracker.name2_iphone', 'home') }}
And then use that to trigger an ‘away from home’ event if we’ve left the garage door open.
alias: Workshop door left open - away from home
description: ""
triggers:
- triggers:
- trigger: state
entity_id:
- binary_sensor.adult_phones
to: null
conditions:
- condition: not
conditions:
- condition: state
entity_id: cover.workshop_door
state: closed
- condition: state
entity_id: binary_sensor.adult_phones
state:
- home
actions:
- action: notify.mobile_app_name1_iphone
metadata: {}
data:
message: Workshop door was left open
- action: notify.mobile_app_name2_iphone
metadata: {}
data:
message: Workshop door was left open
mode: single
It’s being weird, because it seems to trigger when one of us is away from home, even though the helper/binary presence sensor looks like I managed to get it right when it shows the green or red icons within the automations gui.
As always, I’m positive I’ve messed something up in my attempt, so if anyone has an obvious gotcha I’ve done here, please let me know.
The GUI wants you to select the optionHome, which will be set as "on" in the YAML… you have typed “home” and added it as a custom state value… probably inadvertently by hitting enter.
Regarding the Trigger, you may want to move to the new purpose specific trigger, which incorporates a behavior option so it can only trigger when the last listed person or device_tracker leaves:
Don’t make new persons for new devices. If you have multiple devices (e.g. my phone and my ipad), log into them with the same person, but remove the device tracker belonging to the device that stays home from your person entity.
Now you have two devices tracking location, but only one person that gets its location from only one of the devices. Zones only track persons, not device trackers, so the count is right.
The other option is of course not to allow the 2nd device to track location.
People also suggested to create extra users only, not persons. That would be the most simple option, and the one that makes sense if the device has another default dashboard, or for teenagers who leave the device home. But when I tried once I could not get them to log into the companion app. Maybe I did something wrong, maybe it does not work (any longer). For me it makes sense to log in as myself on two devices.
I’ve reverted one of the automations to the below to see if it does actually still work. I think I had a red herring I was dealing with before when I thought it was broken. My wife’s phone wasn’t reporting it was actually “away” which after searching seems to be a thing requiring a reboot.
condition: state
entity_id: zone.home
state:
- "0"