Extra device added to home broke Zone Home = 0 :(

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.

Thanks for reading.

A binary sensor will never have the state home… only on or off.

You know what, I read that was the case somewhere, but the gui keeps wanting to put it in. I changed it in the yaml and again, the gui replaced it.

I bet it’s something stupid I’ve done.

The GUI wants you to select the option Home, 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:

trigger: zone.left
target:
  entity_id:
    - device_tracker.name1_iphone
    - device_tracker.name2_iphone
options:
  for: "00:00:00"
  behavior: all
  zone: zone.home

Okey dokey. Thanks.

I’ll report back. Out at the moment and I’ve already been alerted again, so some part of it was always working.

Sounds like I don’t even need the adult_phones helper with that zone left thing? I’ll go and read up on that new feature.

If one is always there, subtract one from the value and use that.

One (or more) of the devices registered always stays here. So I’m not confident that would work sadly.

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 don’t think I am creating new persons for new devices. I do have multiple devices and have had for a long time, all of mine are signed in as me.

I didn’t realise that Zones only track persons though. Perhaps I should have left it as it was :slight_smile:

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"