HomeKit Does indeed work with Apple TV 3rd Gen its just restricted on some areas (doesn’t support remote access for shared users or remote access to HomeKit enabled cameras)
Yes, well, you did ask if it would work for your roommate …
And that’s a fail.
After three days of responsive tracking homekit just thought my phone was away while I was sitting here with my phone next to me. No good if I’m going to use it to activate my alarm system.
Sigh. Back to the drawing board.
I’ve had similar experience so far. Pretty good, but missed a couple times.
I have a Bayesian sensor, that seems to be working well.
I use the HA app (since I need to have that installed anyway, plus I use it for some automations that are zone dependent., HomeKit, since it does not really require any more overhead on my iPhone since it’s using native iOS calls, and my router, since my phone connects to wifi anyway. I have an asus router, so I use asuswrt.
Those three seem to be a great combination for me, I’ve removed OwnTracks and not looked back.
I might try that. How quickly does it recognise you have returned home?
This is mine. The input Boolean is my HomeKit, the other two are HA app, and last is router.
When I come home Homekit tends to show present 1st, and that is enough to trigger this as On (aka home). As far as triggering away, it takes multiple items to go away. But router is always correct for me, and one of the other sensors usually goes “away” quickly.
Bottom line, for the past week that has been great
- platform: bayesian
prior: 0.6
name: Paul Presence
probability_threshold: 0.9
observations:
- entity_id: 'input_boolean.paul_present'
prob_given_true: 0.9
prob_given_false: 0.1
platform: 'state'
to_state: 'on'
- entity_id: 'device_tracker.pauls_iphone'
prob_given_true: 0.9
prob_given_false: 0.2
platform: 'state'
to_state: 'home'
- entity_id: 'device_tracker.pauls_iphone_2'
prob_given_true: 0.9
prob_given_false: 0.4
platform: 'state'
to_state: 'home'
This is strange… HomeKit is about 99% for me - I have an automation open my garage door when I come home and it’s like magic … I drive up and don’t even completely stop, the door opens.
I think in the month or two I’ve been running this, I can count on one hand the number of times it “missed”
Are you sure the automation was correct and did not change? I noticed in the past it was for some reason tracking my ipad instead of my phone. For most people homekit seems to be very reliable.
Yes. I can see the state change of the homekit input_boolean in history.
Something odd happened again today. I went for a short ride that HomeKit recognised. Then not long after I returned home I was sitting with my phone within 2m of the wifi access point and HomeKit momentarily set me as away twice.
More oddness from the homekit tracker today. The iphone app tracker was 100% for a change though.
The only presence sensor I have found to be 100% accurate is tracking via my router (asus). I’m giving up on the other two (HomeKit and iOS).
I agree for the most part. I have the exact same setup as you (I think).
I use asuswrt, iOS, and Homekit with a switch.
I agree that asuswrt is rock solid, but here are the downsides for me.
-
Even though it my signal strength is strong, it’s not strong enough for some routines, like open the garage door when I get home. With the other sensors (when they are working), my garage door is opening as I pull up, or just opened 10 seconds before. I like that. I don’t want to have to wait for wifi to connect and sit in my car.
-
sometimes I might have a reason to have my wifi off on my phone. I don’t want to trigger away automation’s. I will say this is not super common, but it does happen for me once in a while.
Using these three as a Bayesian sensor has been much, much better for me. If you already have an apple TV, or Ipad for homekit, and have an iphone, why not use them. Just don’t use them in your automations, use the Bayesian sensor.
But again, totally agree with your frustration. It seems to be the hard part for most systems, I know I struggled with this with SmartThings as well. I ended up with three different apps on my phone and wifi as well to get a pretty stable presence sensor.
This really got me thinking and I have a few thoughts/Ideas. For my automations I have two types of needed presence deteection.
-
Am I home? Does not need to be instant, just reasonably quick. I’d use this to send me alerts, if I was not home and the windows were open, or maybe for a possible burglar alarm. Motion in the house, while away.
-
Did I just get home? Things you want to do as soon as you arrive or leave. Unlock doors, open garage, turn on lights, announce arrival with TTS, etc.
The more I thought about it, the more I realize (IMO), that there is not an all in one solution. So I’ve just updated my automations, groups, and sensors based on this.
So for the 1st one. Am I home? I’m using the Bayesian sensor. I’ve tweaked it a bit, so that it requires two of the three to be true to be “ON”. This should be solid.
- platform: bayesian
prior: 0.6
name: MePresence
probability_threshold: 0.9
observations:
- entity_id: 'input_boolean.me_present' #Homekit Switch
prob_given_true: 0.9
prob_given_false: 0.2
platform: 'state'
to_state: 'on'
- entity_id: 'device_tracker.me_iphone' # iPhone HA/GPS
prob_given_true: 0.9
prob_given_false: 0.4
platform: 'state'
to_state: 'home'
- entity_id: 'device_tracker.me_iphone_2' # ASUSWRT
prob_given_true: 0.9
prob_given_false: 0.2
platform: 'state'
to_state: 'home'
I then created a group with both Iphones for some automations
me_iphone_presence:
name: me Iphone Presence
icon: mdi:account-multiple
view: no
entities:
- device_tracker.me_iphone
- device_tracker.me_iphone_2
Also created a simple automation to turn off HomeKit, just in case it gets stuck on. I use the Bayesian Sensor as the trigger. Since the Bayesian sensor requires at least two to be Present to be on, if the HK switch is on, then it’s probably stuck.
##########################################
## Homekit Presence Fixes JIC ##
##########################################
- alias: 'Homekit Stuck fix for Me'
trigger:
- platform: state
entity_id:
- binary_sensor.multiple_presence_me
to: 'off'
action:
- service: homeassistant.turn_off
entity_id: input_boolean.me_present
lastly, for automations that I want to run as soon as I get home, I’m going to use this as my trigger. Of course you’ll have to tweak to make sure automations dont run twice since that could happen.
- alias: generic automation name
trigger:
- platform: state
entity_id:
- input_boolean.me_present #HK
to: 'on'
- platform: state
entity_id:
- device_tracker.me_iphone # iPhone/HA GPS
- device_tracker.me_iphone_2 #AsusWRT
to: 'home'
I chose to use the device trackers for the Iphone seperatly vs the group, just in case one of them got stuck in the wrong state.
Again, I’ve found that the HK switch is very good at “turning on”, but only pretty good at turning off. The asuswrt like you said, is nealry flawless, but has a smaller range.
Anyway, it’s a bit of extra work, but I think worth it. Easy to repeat. I’m sure I could do this a bit simplier, but the main goal was to break up my presence into those two catgories vs trying to make a all in one solution that only worked 90%
I had this working for a few days. Then I added my girlfriends iPhone 7 to this, and we share the same Apple-ID. Now my presence is linked to when she is home/away. What can I do to address this?
Stop sharing an AppleID.
Guess Ill just have to do that then. Family Sharing, here I come
An AppleID has always been meant to be tied to an individual. If you share AppleID’s then your chats, contacts, etc. are also shared. It’s effectively the same as trying to share a single email account.
Apple, of course, didn’t make things easy by not having some sort of “family” system in place until recently.
I moved my gf to her own Apple ID and now all is well. Thanks for a Nice guide, it is working nicely for me
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
This works perfectly! I’d been struggling with “presence” detection. Had tried the ubiquity and nmap compoents. Each kept “losing” my iPhone regularly. Also tried HA iOS app… not so great during development as it seems you need to re-enable location tracking every time you restart HA.
Thanks for the idea and instructions!