Implement ESPresense fuctionality in Home Assistant taking advantage of ble_proxy of ESPHome

Hi,

With the recent expansion of Bluetooth capabilities in Home Assistant, including the BLE Proxy functionality of ESPHome, as well as code available from other open-source projects, I think the pieces exist to have an Apple device presence sensor, which would also probably work for none-Apple devices.

Currently, I am using ESPresense to track Apple devices after finding out their IRK (Identity Resolving Key) - this is detailed at Apple | ESPresense.
This works well, however, the drawback is that I already use ESPHome BLE Proxies for a bunch of Xiaomi and other Temp and Plant sensors, so adding ESPresense essentially doubles the number of ESP32 devices I need to deploy.

When I look at the verbose logging from ESPHome, I can see that it is already forwarding all the relevant packets to Home Assistant…

[10:06:55][V][bluetooth_proxy:033]: Proxying packet from  - AA:AA:AA:AA:AA:AA (Apple iPhone). RSSI: -69 dB
[10:06:56][V][bluetooth_proxy:033]: Proxying packet from  - AA:AA:AA:AA:AA:AA (Apple iPhone). RSSI: -69 dB
[10:06:57][V][bluetooth_proxy:033]: Proxying packet from  - AA:AA:AA:AA:AA:AA (Apple iPhone). RSSI: -70 dB
[10:06:57][V][bluetooth_proxy:033]: Proxying packet from  - BB:BB:BB:BB:BB:BB (Apple iPad). RSSI: -85 dB
[10:06:57][V][bluetooth_proxy:033]: Proxying packet from  - CC:CC:CC:CC:CC:CC (Apple Watch). RSSI: -75 dB
[10:06:57][V][bluetooth_proxy:033]: Proxying packet from  - AA:AA:AA:AA:AA:AA (Apple iPhone). RSSI: -69 dB
[10:06:58][V][bluetooth_proxy:033]: Proxying packet from  - AA:AA:AA:AA:AA:AA (Apple iPhone). RSSI: -69 dB
[10:06:59][V][bluetooth_proxy:033]: Proxying packet from  - CC:CC:CC:CC:CC:CC (Apple Watch). RSSI: -77 dB
[10:06:59][V][bluetooth_proxy:033]: Proxying packet from  - AA:AA:AA:AA:AA:AA (Apple iPhone). RSSI: -70 dB
[10:06:59][V][bluetooth_proxy:033]: Proxying packet from  - BB:BB:BB:BB:BB:BB (Apple iPad). RSSI: -86 dB
[10:07:00][V][bluetooth_proxy:033]: Proxying packet from  - CC:CC:CC:CC:CC:CC (Apple Watch). RSSI: -75 dB
[10:07:00][V][bluetooth_proxy:033]: Proxying packet from  - AA:AA:AA:AA:AA:AA (Apple iPhone). RSSI: -71 dB
[10:07:00][V][bluetooth_proxy:033]: Proxying packet from  - BB:BB:BB:BB:BB:BB (Apple iPad). RSSI: -84 dB
[10:07:01][V][bluetooth_proxy:033]: Proxying packet from  - BB:BB:BB:BB:BB:BB (Apple iPad). RSSI: -87 dB
[10:07:03][V][bluetooth_proxy:033]: Proxying packet from  - AA:AA:AA:AA:AA:AA (Apple iPhone). RSSI: -71 dB
[10:07:03][V][bluetooth_proxy:033]: Proxying packet from  - BB:BB:BB:BB:BB:BB (Apple iPad). RSSI: -81 dB
[10:07:03][V][bluetooth_proxy:033]: Proxying packet from  - CC:CC:CC:CC:CC:CC (Apple Watch). RSSI: -79 dB
[10:07:04][V][bluetooth_proxy:033]: Proxying packet from  - AA:AA:AA:AA:AA:AA (Apple iPhone). RSSI: -77 dB
[10:07:04][V][bluetooth_proxy:033]: Proxying packet from  - CC:CC:CC:CC:CC:CC (Apple Watch). RSSI: -78 dB

So the feature request is for a new HA component that would allow the adding of Apple devices after discovering the IRK, and then have their presence (and possibly even room / area location) tracked.

I think the reverse engineering work on the Apple protocols here GitHub - furiousMAC/continuity: Apple Continuity Protocol Reverse Engineering and Dissector may also be of relevance.

Thanks

Dan

I too have this challenge, using ESP32’s in my smart home for both ESPresense AND other functions is a shame. It would be great to have this functionality included in ESPHome so that we can use the ESP’s we have to it’s fullest potential.
Please note that having the “room” function is very usefull in order to track devices to specific rooms. And when I say devices I’m thinking of both Apple, Android or smart trackers (using bluetooth)…

1 Like

I have cross-posted this feature request in ESPresense at Implement ESPresense fuctionality in Home Assistant taking advantage of ble_proxy of ESPHome · Issue #795 · ESPresense/ESPresense · GitHub and changed the title as I think it has much broader applicability than just Apple devices

1 Like

I wonder if you could adapt this? GitHub - dalehumby/ESPHome-Apple-Watch-detection: ESPHome BLE Apple Watch presence detection

Any movement here?

This has been done in 2023.10:

Still need one ESPresence device to extract the IRK, but only once.

1 Like

Just learned about this from your post, and this seems to work very well with my iPhone + ESPHome on my ESP32s. Thank you for sharing!

You‘re welcome.

One thing I noticed in my home though was that one has to be strategic about the placement of the ESP devices, when trying to do indoor tracking. Which BT-device is registered as the closest to my iPhone often changes in my home even when the device is not moved at all, and it‘s often not true.

I ended up with reporting the floor instead of the room (which is enough to find it …).

Would you guys mind sharing how you did this? I started with the Private BLE integration and have the IRKs from the iDevices I want to track- that integration works ok by itself but I need a proxy away from the server, so I got ESPHome running and an ESP32 board online, but I can’t figure out what to do now.