Presence of the persons of my family

I’m having loads of fun with the presence part of Home Assistant. I have the Life360 app on my Android phone, and my wife and two kids have an iPhone that I track with the excellent iCloud3 component for Home assistant. And I have a couple of Raspberry Pi’s with Monitor.sh in my house to track the presence of the bluetooth signals of our phones and of my Mi Band 3.

Now I would like to switch off all the lights when the last person leaves the house. So I configured the members of our family with the new Person component like this:

person.dad -> device_tracker.life360 + device_tracker.bt
person.mum -> device_tracker.icloud + device_tracker.bt
person.child1 -> device_tracker.icloud + device_tracker.bt
person.child2 -> device_tracker.icloud + device_tracker.bt

And I configured a template like this in my configuration.yaml:

   - platform: template
     sensors:
       people_home:
         friendly_name: 'People Home'
         device_class: presence
         value_template: >
           {{ is_state('person.husband', 'home') or
              is_state('person.wife', 'home') or
              is_state('person.kid1', 'home') or
              is_state('person.kid2', 'home') }}

So now I got a “binary_sensor.people_home” that is ‘on’ or ‘off’. I made an automation to switch off all my lights when the binary_sensor switches to off.

I read https://www.home-assistant.io/components/person/ about how smart the person component is with a combination of bluetooth and GPS based device trackers.

But still: when my wife is at home, and the Bluetooth sensor switches to off because her phone is out of reach of my bluetooth monitors so the device_tracker.wife_bluetooth switches to not_home, her person.wife is still “home”, but the binary_sensor.people_home is switches to ‘off’. And the lights turn off :slight_smile:

So it seems that the last change in one of the device trackers decides the state of the binary sensor… Since her icloud3 devicetracker still says home the binary sensor should stay on I think… but it doesn’t work that way?

That is not how it is described in the https://www.home-assistant.io/components/person/ documentation.

Am I doing something wrong or is this a bug?

Sorry to start with the nag but please use preformatted text button </> when posting code or config, makes it much easier to read.
You have alighted on a subject close to my heart (read: bl33ding infuriating !)
I have gone through most peoples solutions and was still a bit ‘mmmmph !’
I think you are on the right track regarding the binary_sensors
Set up one for each person and debounce them a bit.
Then combine them in another binary_sensor for house occupied and debounce that with a configurable timer (I have this set on 0 mins at the moment but will extend it if it causes me trouble)

individual sensor : -

      bs_occupied_muttley:
        entity_id: device_tracker.life360_muttley, input_boolean.ib_occupied_muttley_away
        value_template: "{{ is_state('device_tracker.life360_muttley', 'home') and is_state('input_boolean.ib_occupied_muttley_away', 'off') }}"
        friendly_name: Muttley At Home
        delay_off: "00:00:10"

OR in any extra devices you want to use
house sensor : -

      bs_occupied:
        entity_id: binary_sensor.bs_occupied_muttley, binary_sensor.bs_occupied_adrianna, input_boolean.ib_occupied_force, input_boolean.ib_occupied_retention
        value_template: "{{ is_state('input_boolean.ib_occupied_forceon', 'on') or is_state('input_boolean.ib_occupied_retention', 'on') or is_state('binary_sensor.bs_occupied_muttley', 'on') or is_state('binary_sensor.bs_occupied_adrianna', 'on') }}"
        friendly_name: House Occupied
        delay_off: "00:00:10"

the input_boolean.ib_occupied_retention is put on in the script that runs your variable timer and turned off again at the end of it. The script is triggered when ALL your away catagories are satisfied.

I have included ‘Evict Muttley’ (the muttley_away one) just in case Muttley leaves his phone at home (do for all forgetful people (most human beings, but generally NOT muttley !)), and I’ve also allowed a bit to force occupation ‘on’. Just incase we have guests staying or contractors in etc.
Note you have to list the entity id’s of devices that need to be monitored for the sensors, or updates will be a bit random.
Hope this helps

I handle this by:

  • Tracking each individual separately
  • Handling the family based upon the state of the individuals
  • Not using person :wink:

This final article explains how I do it in detail, but effectively I’m using the state of a group of device trackers, and whether an exit door has recently opened, to control the state of a boolean for each individual. The boolean is only turned off if the group is not_home and an exit door was recently used.

Person is getting better, it used to simply use last to update wins, but it has no capability to be managed with things like door sensors.

I think I found something: the iCloud3 component is sometimes setting the status to “Thuis” instead of “Home”. So the Dutch word, not the English one.

So I change my code to this:

  - platform: template
    sensors:
      people_home:
        friendly_name: 'People Home'
        device_class: presence
        value_template: >
          {{ is_state('person.husband', 'home') or
             is_state('person.husband', 'thuis') or
             is_state('person.wife', 'home') or
             is_state('person.wife', 'thuis') or
             is_state('person.kid1', 'home') or
             is_state('person.kid1', 'thuis') or
             is_state('person.kid2', 'home') or
             is_state('person.kid2', 'thuis') }}

Things look good now!

Greetings,
Harry Westerman

2 Likes