Person vs. Bayesian

Hi HA comrades,

I’m trying to set up device tracking / presence detection that works well. I have previously set up the person component in the config file with hardcoded information and recently found that it can be fully configured from within home assistant so I removed my hard-coded entries in the configuration.yaml file and configured them more dynamically. However, a friend of mine told me about the Bayesian Binary Sensor component which seems much more powerful than the person component but it seems to create binary sensors instead of person entries. Is there some way to integrate the two so I take advantage of both at the same time?

Thanks,
-Greg

You can use a few automations to create and change the state of a device_tracker entity based on the status of another type of entity. In my case I use an input_boolean entity that a HomeKit automation turns on an off based on the location of my iPhone. I wanted to use HomeKit to help determine presence without any additional software loaded or having to sign in to iCloud in HASS.

In HASS there are a few automations to create a device_tracker entity and then watch the input_boolean state to trigger a change in state of the device_tracker entities they created. I can then incorporate the device_tracker states into a person entity, since they only support device_trackers. You only need one number 1 automation and a 2 and 3 automation for each device.

Automations:

  1. Create device_tracker entities. This runs at system start and you can define multiple device_trackers by adding additional data entires
  2. Home automation
  3. Not Home automation

Here are my automations entries. In your case you would trigger them based on your Bayesian Binary sensor states.

# Automation 1
- alias: 'HomeKit: Device Tracker Init'
  initial_state: False
  trigger:
    platform: homeassistant
    event: start
  action:
  - data:
     #becomes the name of the device tracker
      dev_id: device1_homekit 
      gps_accuracy: 90
    service: device_tracker.see

#Automation 2    
- alias: 'HomeKit: Device1 Home'
  initial_state: True
  trigger:
  - platform: state
    entity_id: input_boolean.device1_homekit_sensor
    to: 'on'
  action:
  - data:
      dev_id: device1_homekit
      location_name: home
    service: device_tracker.see

#Automation 3  
- alias: 'HomeKit: Device1 Away'
  initial_state: True
  trigger:
  - platform: state
    entity_id: input_boolean.device1_homekit_sensor
    to: 'off'
  action:
  - data:
      dev_id: device1_homekit
      location_name: not_home
    service: device_tracker.see
2 Likes