Presence is one of the cornerstones of a good home automation system. HomeAssistant offers multiple methods of detecting presence. Unfortunately, however, any single method is far from reliable. Like most of you, I struggled a multiple presence detection methods to improve the wife acceptance factor. After lot of iterations, I (think) have the perfect system that detects presence very reliably and I thought of sharing the same with you.
Given that any one method is not entirely reliable, I use multiple presence detection methods. I am currently using three methods - the HA iOS app, Owntracks/MQTT, and Asuswrt. The basic premise (or hope) is that at least one of them is right and, not surprisingly, it is the one that was updated most recently. All, we need is to create rules/automations that utilize the most recently updated tracker.
I created an input_boolean
that keeps track of whether I am home
or not_home
.
input_boolean:
alokhome:
name: Alok Home
initial: on
icon: mdi:cellphone-iphone
Next, I created automations that will update the input_boolean
variable whenever any of the device_tracker
updates. Hereās an example of the automation (note the three entities are for the three trackers that I am using):
- alias: 'Mark Alok Away'
condition:
condition: state
entity_id: input_boolean.alokhome
state: 'on'
trigger:
- platform: state
entity_id: device_tracker.myiphone
state: 'not_home'
for:
minutes: 10
- platform: state
entity_id: device_tracker.pi_alokphone
state: 'not_home'
- platform: state
entity_id: device_tracker.alokiosiphone
state: 'not_home'
action:
- service: homeassistant.turn_off
entity_id: input_boolean.alokhome
- alias: 'Mark Alok Home'
condition:
condition: state
entity_id: input_boolean.alokhome
state: 'off'
trigger:
- platform: state
entity_id: device_tracker.myiphone
state: 'home'
- platform: state
entity_id: device_tracker.pi_alokphone
state: 'home'
- platform: state
entity_id: device_tracker.alokiosiphone
state: 'home'
action:
service: homeassistant.turn_on
entity_id: input_boolean.alokhome
These automations will ensure that input_boolean.alokhome
will always have the most updated information about my status. You can add as many trackers as you want (more the merrier) and then use the input_boolean.alokhome
for any subsequent presence-based automations.
This probably is nothing new to most of you, but it took me a while to figure out and hope this is useful for some of you. I have been using this system for a while and am very happy with it. Please let me know if you have any feedback.