Person, House and Door component ideas

Hi there. I like the new Person component, but it is a bit “unreliable” as a person tracker still for me to replace my own template sensor used for the purpose.

Maybe this can be to inspiration to further develop or maybe for others as inspiration :slight_smile:

My ideas started from this guide:
Making Home Assistant’s Presence Detection not so Binary

But I found a template sensor to be more reliable than a automation to switch states

My current sensor has these states: Just Arrived / Home / Just Left / Away / Extended Away / Sleeping

From all (both persons) statuses I have a separate similar sensor for the whole house with the states:
Just Arrived / Home / Just Left / Away / Extended Away / Silent / Sleeping

Each person has these sensors:

binary_sensor.person_occupancy
A template sensor created off device_trackers (bluetooth, wifi and GPS)
BT/Wifi has priority and decides occupancy is ON unless GPS leaves a zone around the house.
The zone alone is not enough to decide “Home” on its own as the zone is set fairly large (250m)

input_binary.person_awake
Contolled by bedside switch, google home routine + automation to set person to “sleeping” if person is home and a “awake detection” template sensor for the whole house is not active and it is “nighttime”

binary_sensor.awake_detection
Awake detection is a template sensor created off motion sensors outside the bedroom, devices that will indicate someone is awake like the coffee-brewer, bathroom humidity delta (humidity in bathroom vs whole house) is rising (someone is showering), chromecast starts streaming, TV turns on etc.

If there is only one person home, the “awake detecton” will switch that persons input_binary-person_awake to ON, which will then cause the persons “status”-sensor to switch from “Sleeping” to “Home”

Some extra info/useful automations:

  • Person can only be “Sleeping” if Home/Just Arrived
  • If neither BT or WiFi is tracking the person for 5 minutes the person is first set to “Just Left” and changes to “Away” after 15 minutes. This defaults a person to “Just Left” if HA is restarted until BT/WiFi detects the phone.
  • If all occupants are Away it will turn off TV, stop media players, turn off coffee machine if it is on (power >5W for the plug)
  • If Away for more than 24 hours -> Extended Away
  • If all occupants is Extended Away the house will also be “Extended Away” which will lower temperature setpoints in the house/disable cooling in the summer.

Something I want to add possibly:

  • If the entry door has not changed status, no person should be set away

This also brings up the template sensor I have for the door combining the lock and the door magnet:
States: Locked / Unlocked / Open / Jammed

Uses status from the Danalock to tell if it is Locked / Unlocked and a door magnet to indicate Open / Closed

  • Door is closed and locked = LOCKED
  • Door is closed and unlocked = UNLOCKED
  • Door is open and unlocked = OPEN
  • Door is open and locked = JAMMED

If the house status is Home/Just Arrived it will unlock the door if the door is locked in a “open” state.
The door will not change status if all occupants are sleeping or nobody is home.

Hi,
I also oriented myself on Phil’s guide for non binary presence detection introducing additional states just like yourself. I created the automations initially just like Phil, but found out that to prevent a few state transitions further conditions are necessary, which makes the automation a little more complicated. As I am still new to Home Assistant and still learning, I prevented to mix to merge the various personal of the household in one automation, especially because sometimes the transitions vary.
I for example always enter airplane mode, when asleep. This information can be used to trigger the asleep transition. My wife not so … and I shall not try to change her behavior. You probably heard about the WAF.
I am wondering how did you, @forschi, use template sensors? Would you mind sharing?

An additional question is regarding the status of the group of all persons. As the sensor is no trivial device tracker and the logic is also more complicated, it does not automatically carry the state of its children (the persons) how did you populate it with logic?

Following are the ideas I had in my mind:

To find out if a person just left, I would like to use the trigger of my netatmo presence camera detecting a person together with the persons device no longer available in the wifi (device_tracker). My assumption is that the wifi is still available around the house and the not_home detection of the device_tracker is delayed compared to motion detection. But I do not know yet how to include this logic (see red example on person1).

Any suggestions?

I am guessing the right way to check would be to use the netatmo motion detection as an additional condition:

trigger:
  - platform: state
    entitiy_id: device_tracker.pers1
    from: 'home'
    to: 'not_home'
condition:
  - condition: or
    conditions:
      - condition: "{{ states('Input_select.pers1_status_dropdown') == 'Just Arrived' }}"
      - condition: "{{ states('Input_select.pers1_status_dropdown') == 'Home' }}"
  - condition: event
    event_type: netatmo event
    event_data:
       type: human
#tbd: somehow check if that event was fired within the last i.e. 5 minutes