ESPHome and BLE room level presence detection

I have a few ESP32 boards that I want to use for room level presence detection.

The Bluetooth devices Im trying to detect has random MAC addresses assigned:

[19:08:47][D][esp32_ble_tracker:148]: Starting scan...
[19:08:47][D][esp32_ble_tracker:544]: Found device 71:A7:0C:88:4E:28 RSSI=-56
[19:08:47][D][esp32_ble_tracker:565]:   Address Type: RANDOM
[19:08:47][D][esp32_ble_tracker:544]: Found device 28:FF:3C:B0:6F:7B RSSI=-89
[19:08:47][D][esp32_ble_tracker:565]:   Address Type: PUBLIC
[19:08:47][D][esp32_ble_tracker:569]:   TX Power: 2
[19:08:48][D][esp32_ble_tracker:544]: Found device 68:C5:2C:2B:86:F8 RSSI=-39
[19:08:48][D][esp32_ble_tracker:565]:   Address Type: RANDOM
[19:08:48][D][esp32_ble_tracker:569]:   TX Power: 2
[19:08:49][D][esp32_ble_tracker:544]: Found device 1B:5D:03:19:A6:1E RSSI=-42
[19:08:49][D][esp32_ble_tracker:565]:   Address Type: RANDOM
[19:08:50][D][esp32_ble_tracker:544]: Found device 45:72:A5:66:04:CC RSSI=-68
[19:08:50][D][esp32_ble_tracker:565]:   Address Type: RANDOM
[19:08:50][D][esp32_ble_tracker:569]:   TX Power: 2
[19:08:54][D][esp32_ble_tracker:544]: Found device 7C:9A:D5:83:18:76 RSSI=-40
[19:08:54][D][esp32_ble_tracker:565]:   Address Type: RANDOM
[19:08:54][D][esp32_ble_tracker:569]:   TX Power: 2
[19:08:55][D][esp32_ble_tracker:544]: Found device 1C:4E:A7:7B:F4:6F RSSI=-87
[19:08:55][D][esp32_ble_tracker:565]:   Address Type: RANDOM

So I cant track by MAC address.

Almost all the devices I want to track are Apple based devices.

I downloaded nRT Connect to see if I can find the UUID for some of the devices. Ive been able to get a couple of UUIDs for one of my older Apple Watch to test.

The device however never gets detected even when I try different or multiple UUID’s. Device always remains Off in Home Assistant.

Current config in ESPHome as follows (only the BLE section):

esp32_ble_tracker:

binary_sensor:
  - platform: ble_presence
    service_uuid: '9FA480E0-4967-4542-9390-D343DC5D04AE'
    name: "Apple Watch 3"

I have a few other sensors I am connecting to the ESP32’s including a PIR, light and temperature sensor that all see to work fine.

Ive looked at turning the ESP32’s into beacons:


Problem with this is I them need a app on the devices to detect the beacon.

Ideally I would like to be able to track devices without having to install a app. So tracking the device from the ESP instead of the devices triggering the automation.

If anyone has managed to get device tracking working with a ESP32 and ESPHome I would appreciate any advice!

1 Like

Do you use the home assistant app?
That includes a beacon you can detect with the esp

I I do have the Home Assistant app on my devices yes. But I cant find what you are referring to? Can you share a link please?

Found the mobile integration. Doesnt seem to work with iOS.

I would like to do something similar also.

My Android phone also didn’t work with the Home Assistant app beacon feature.

Have you found a solution?

Info on working setup would be appreciated, i.e. ESP32 BLE Tracker and Home Assistant Companion App (Android).

I’ve done quite a bit of research on these trackers. If you are trying to track an apple device it will be a bit more difficult. They have some strange protocol in place. I don’t have as much experience with the ESPHome version of the tracking, I actually found this post in the process of looking into switching to it so I can consolidate the number of ESP32s I am using in one spot, but I do know that ESPresense (NOT ESPHome based) can detect iDevices as long as you set it up properly, it is all documented very well. Yes I know they spelled Presence incorrectly.

“The newest version allows you to selectively decide which ids you want queried to improve the id. You can now put “apple:1005:9-12” in the query box and it’ll ask the phone for it’s model and turn it into “apple:13-3”. BUT if apple:1005:9-12 is working for you reliably it’s better just to use that and keep query empty. The ESP32 has to stop listening while sending out the queries which hurts the reliability of receiving advertisements from devices.”

Hi,

I created a feature request outlining a way to solve this problem, if you’re like to look at Apple Devices Presence using ESPHome BLE Proxy (ESPresense alternative)

Thanks

Dan