HomeKit as a Presence Sensor

Hey all.
Just curious - does everyone using an Apple TV have the ATV wireless or wired connection? I had massive problems when wired - when my phone was outside of home Wi-fi no HA devices would show in Home app (all would say Unreachable). But when I got home the Home app would show all devices properly again. This meant that when anyone went away from home the HA switch automation would activate as ATV didn’t know people had left

I’m wired, and it’s been solid for so long I actually never even think about it anymore. Both my wife and I use it.

Same for me, last update somehow fixed i think.

I haven’t read all the comments, but this is my config: I have my router enabled as device tracker and added all MACs of Iphones etc. to known_devices. The device trackers are linked to persons and to have them show in Homekit I added this:

known_devices.yaml:

johnIphone:
  hide_if_away: false
  icon:
  mac: [MAC]
  name: johnIphone
  picture:
  track: true

joeIphone:
  hide_if_away: false
  icon:
  mac: [MAC]
  name: joeIphone
  picture:
  track: true
  
sarahIphone:
  hide_if_away: false
  icon:
  mac: [MAC]
  name: sarahIphone
  picture:
  track: true
  

configuration.yaml:

device_tracker:
  - platform: [name of supported router]
    host: [ip address]

homekit:
  filter:
    include_entities:
      - person.john
      - person.joe
      - person.sarah

The Automations are made in Homekit. It works perfectly.

I got a weird issue setting this up. Everything seems to work ok. I can toggle on/off from the app and browser while connected to my home network. However, if I am out of my network or just turn off wifi from the phone, it shows not responding. The weird issue is that all my other lights I have connected to HK works. It’s only the this one switch shows not responding. I am not sure where to look.

Seems like I needed a reboot of Apple TV.

Detection no longer working reliably.

Since iOS 14 and probably around release .115.x, I have had troubles with using homekit as a presence sensor. I had been using it since 2018, with good success.

What happens is that currently the sensor may or may not get updated either on or off for presence .
anyone have any ideas? I am using an Apple TV 4K as the home hub, and using 2 iphones, a 7 and an iphone SE(first version). Both of the phones are updated to latest 14.x and the Apple TV is also updated to latest version for it.

I am also currently running HA core v.117.5 .

If anyone knows how to enable the appropriate debug in HA core, I might then be able to tell if the problem lies with iOS or HA.

Thanks in advance!

One thing to take into account is that the tracking only really reports if you’re near home. The Bayesian sensor is a good way to incorporate everything together along with conditional automation. Ie if you put your code in on the smart lock then you’re definitely home. Or if you are near home then the front door opens. Use wifi as another one. I kinda over engineered mine because I’m a telecom project manager and engineer and this is my OCD outlet. Thought there was a real world need. Ie I may drive near the house on the way somewhere else due to the neighborhood cut through between two main thoroughfares. The other was my office is in a very central location and I’d trigger my at work automations when i was in its area. Individual routines bear an impact like I am near home but haven’t gone in the house yet went straight to the garage for a smoke. Don’t have a code on the garage but have it’s motion sensor. The other thing was at least on HomeSeer my network monitor didn’t instantly pick me up though I think the unify monitor here does. I don’t have a code on the garage door but have a door sensor there. Stuff like that

Long shot but do you have “Private Address” enabled on the phones connected to your wifi network? This scrambles the WiFi MAC address so that tracking cannot be done. It caught me out when the family updated to iOS 14.

2 Likes

I did have Private Address enabled, so I have now re-enabled it. Now for testing to see if that was it.

Thanks for the hint!

Well, since I have disabled Private Address I have not seen any change in behavior.

Any other ideas how i can troubleshoot this? It used to be so reliable, and now is very hit and miss working.

Regards

I am seeing the same thing. Used to be rock solid, now very hit and miss

Crossing fingers, since the 14.2 iOS update, as well as the 14.2 TV OS( I use an AppleTV 4K as the ‘hub’ always inside the house), presence sensing has been good for the past 24 hours.

I just configured this and it seems to work pretty well. Just one miss so far, and it looks like that was due more to my garage state getting stuck in HA.

So far so good, we’ll see how stable it is over the next few months.

So I’m looking at this to just remove the need for two apps to poll my location. Is it still working good?

I figures that Homekit/Apple polls locations every now and then anyways it could save one some battery to just disable location in the HA app and only use the homekit one.

It is now working good for me. The problem I had a few months ago was that my street address did not match 100% what apple had as my street address.

I just read this thread and had to give this one a try! As of now I used OwnTracks for presence detection which basically works well, but sometimes the location stucks for hours. Homekit as an alternative sounds very promising.

So I created an input.boolean to act as a switch and configured an automation (in Homekit) to turn on the switch when I arrive, vice-versa when I leave. I also created a binary.sensor to use it for an automation. This automation created a device_tracker entity which gets updated via the below automation.

alias: Update presence and device tracker Andreas
trigger:
  - platform: state
    entity_id: binary_sensor.presence_andreas
    from: 'off'
    to: 'on'
  - platform: state
    entity_id: binary_sensor.presence_andreas
    from: 'on'
    to: 'off'
condition: []
action:
  - service: device_tracker.see
    data:
      dev_id: tracker1
      location_name: '{{ ''home'' if is_state(trigger.entity_id, ''on'') else ''not_home'' }}'
      source_type: router
mode: queued
max: 10

the issue
I noticed that when I restart Home Assistant on my Raspi the state from home switches to not home.

question
Has anyone else observed this behaviour, if so what can I do to change it? I couldnt find a solution during internet research.

all the best

Andrew

Just a guess. You said:

So I created an input.boolean to act as a switch and configured an automation (in Homekit) to turn on the switch when I arrive, vice-versa when I leave.

Do you have an entry of initial: in the input boolean? If so, remove it completely.

thanks for the reply, I created the input.boolean via the helper section within Home Assistant, unfortunately I cannot set the initial_state there. AFAIK the intial state is optional and not set by default. Also the automation doesnt contain an initial_state.

as of now I created a flow with Node-RED to check if my binary.sensor is on, but I am marked as not_home. If so it updates the status accordingly.

Can someone tell what the default radius is that homekit used before someone is arrive or leave?