I wanted to provide my current setup and using Homekit. It has been 100% for several weeks now. I’ve posted much of this already, but wanted to add a few automations, and just overall processes that have worked very well.
Although I am using Homekit, this generally would work well with any three presence sensors. I feel like solid router based presence is key. GPS based are all pretty good, but as we all know, none of them seem to be 100%. That’s why for some of my automations I trigger on any of the three turning on, or becoming home, and other automations are based on the bayesian sensor.
binary_sensors.yaml
# This will change to on if any two are true, but not is only one is true.
# For me most common is for HK then ASUS, and then close behind HA GPS
- platform: bayesian
prior: 0.6
name: me Presence
probability_threshold: 0.9
observations:
- entity_id: 'input_boolean.me_present' #HK switch
prob_given_true: 0.9
prob_given_false: 0.2
platform: 'state'
to_state: 'on'
- entity_id: 'device_tracker.mes_iphone' #HA Iphone App - GPS
prob_given_true: 0.9
prob_given_false: 0.4
platform: 'state'
to_state: 'home'
- entity_id: 'device_tracker.mes_iphone_2' #ASUS/WRT router based
prob_given_true: 0.9
prob_given_false: 0.2
platform: 'state'
to_state: 'home'
# useful if you want to use the bayesian sensor as a more traditional presence for automations
- platform: template
sensors:
multiple_presence_me:
friendly_name: "me"
device_class: presence
value_template: >-
{{ is_state('binary_sensor.me_presence', 'on') }} # bayesian sensor
# I use this as a senor indicating someone is home
- platform: template
sensors:
people_home:
friendly_name: People Home
device_class: presence
value_template: >
{{ is_state('group.primary_presence', 'on') or
is_state('input_boolean.guests_present', 'on') or
is_state('group.extra_device_trackers', 'home') }}
groups.yaml
primary_presence:
name: Primary Presence for Routines
icon: mdi:account-multiple
view: no
entities:
- binary_sensor.me_presence # bayesian sensor
- binary_sensor.spouse_presence # bayesian sensor
extra_device_trackers:
name: Guest Presence Sensors
icon: mdi:account-multiple
view: no
entities:
- device_tracker.common_guest_visitor #asuswrt
input_selects.yaml
house_mode:
name: Mode
options:
- Home
- Away
- Night
- Extended Away
sensors.yaml
# adding this to my automations stops false alerts or triggers
- platform: uptime
name: "HA runtime in minutes"
unit_of_measurement: minutes
Automations.yaml
# I use the input select of Home, away, to trigger other autmations
- alias: Home Mode - Leaving
trigger:
- platform: state
entity_id: binary_sensor.people_home
to: 'off'
condition:
- condition: numeric_state
entity_id: sensor.ha_runtime_in_minutes
above: 1
- condition: state
entity_id: input_select.house_mode
state: 'Home'
action:
- service: input_select.select_option
entity_id: input_select.house_mode
data:
option: 'Away'
# I list each presence sensor individually just in case I've manually changed the home mode to away for some reason
- alias: Home Mode - Arriving
trigger:
- platform: state
entity_id:
- input_boolean.me_present # HK Switch
- input_boolean.spouse_present # HK Switch
- input_boolean.guests_present # Manually triggered
to: 'on'
- platform: state
entity_id:
- device_tracker.mes_iphone #HA Iphone App - GPS
- device_tracker.mes_iphone_2 #ASUS/WRT router based
- device_tracker.spouse_iphone #HA Iphone App - GPS
- device_tracker.spouse_iphone_2 #ASUS/WRT router based
- group.extra_device_trackers
to: 'home'
condition:
- condition: numeric_state
entity_id: sensor.ha_runtime_in_minutes
above: 1
- condition: state
entity_id: input_select.house_mode
state: 'Away'
action:
- service: input_select.select_option
entity_id: input_select.house_mode
data:
option: 'Home'
# I use the to make to turn off the Homekit switch if the bayesian sensor goes off. More of a safety check
- alias: 'Paul Left'
trigger:
- platform: state
entity_id: binary_sensor.me_presence # bayesian sensor
to: 'off'
condition:
- condition: numeric_state
entity_id: sensor.ha_runtime_in_minutes
above: 1
action:
- service: homeassistant.turn_off
entity_id:
- input_boolean.me_present #HK switch
input_boolean.yaml
guests_present:
name: We have guests
icon: mdi:account-multiple
me_present:
name: Me
icon: mdi:account
spouse_present:
name: Spouse
icon: mdi:account