Leaving Home Zone

Hi Team.

What is the best way to handle this? Both my Mrs and I have iPhones and we are using the companion app. What i am looking to do is that if both of us are not home then to turn off all the lights. But if one of us is still at home to not switch anything off. I thought about using a group helper but not sure from what i can see if i can add our mobile devices.

Any suggestions?

Set both devices in a trigger state node, below in the conditions add each entity separately and use not_home for the state. This will only fire when both entities are away.

e.added pic

I use a template that creates an entity “someone Home”

- platform: template
  sensors:
    someone_home:
      friendly_name: Someone Home
      icon_template: >-
        {% if is_state('binary_sensor.someone_home','on') %} mdi:home-account
        {% else %} mdi:home-outline
        {% endif %}
      value_template: "{{ is_state('person.xxx','home') or  is_state('person.xxx','home') }}"

Probably other ways to do it but it works for me.

Assuming the companion app reporting in and out of the zone correctly, and you have linked the devices (the iPhones) to people… check the status of your Home Zone, you should get numbers:

Starting 2022.4, the home zone should have a state indicating # of people in the zone…
So you likely could just use that state (being 0) to trigger your automation.

No need for any template nor group helper - HA has that already.

But then, yeah, if you want something fancy, you can always bake your templates.

On that note, here’s a good article. It has been a couple of years old, so implementation is different these days (for example we can do group helpers from UI now), but the concept is still relevant and interesting:
Making Home Assistant’s Presence Detection not so Binary – Phil Hawthorne