Bluetooth MAC vs ID in ESPresence

Hey Everyone!

I’ve just set up 5 ESP32 nodes for room presence detection using ESPresence. The nodes are working fine and can be detected by Home Assistant. The next step of setting up which IDs correspond to which devices has me puzzled.

I’ve set up device console logging for a few hours on just one of the ESP32 nodes to see what it sees as far as MACs and IDs. After looking at the results, it found 167 unique MAC addresses, but they corresponded to only unique 18 IDs, of which only 12 were unique MAC-ID pairs. One ID (sd:0xfe9f) had 46 corresponding MAC addresses while another (md:00e0:8) had 95 MAC addresses.

Is it normal to have one ID associated with multiple MACs? Would one device transmit multiple MACs? Going the other direction, only one of the MAC addresses corresponded to two IDs (sd:0x180a21 and sd:0x180a). Is this normal?

Thanks in advance!

Phade.

Yes that’s normal. One ID (UUID) can have a rotating MAC address. Google for BLE MAC randomization will explain why some devices have this implemented.

1 Like

Ahh, good to know!

How would I go about identifying what ID corresponds to which device? Is there a way to track or auto-add newly discovered IDs using Home Assistant or another system other than just keeping the console open?

Thanks again!!

Using MQTT explorer you can see which devices arrive http://mqtt-explorer.com/
Therefrom you can check e.g. the “name” information to identify the devices.

2022-02-19_20-55-36

I am not aware about something already existing to “auto add” newly discovered IDs…but I am interesting in this too (if somewhere out there).
Alternatively I am pretty sure it would be possible to build something using a custom_component or pyscript with something like paho-mqtt · PyPI …but as always - too busy on other topics to do it :stuck_out_tongue: :wink:

I tried today also this great code. My problem is that iPhone change Mac address also , but it gets eveyrtime also a new ID:

Schermafbeelding 2022-02-19 om 21.48.15

Don’t know how to do this with the sensors…

Thank you for the replies!

Interestingly, my MQTT explorer does not show “name” as an attribute. Do I need to specifically configure the system to get the device name (a “verbose” mode)?

Your help is much appreciated!!

After many hours I see that 3 ID have most messages. That can be my iPhone, my partners and my watch… The 4rd can be my iMac (2010)

But I can’t build on this, because it will switch maybe to a different ID…

Schermafbeelding 2022-02-20 om 15.26.29

Hey Everyone!

I’ve let mine run all day and I’ve come up with interesting results. I set each receiver to only report at 3 meters and this is what I got:

The top three results are most likely in my house. However, the pings jump around constantly, especially this last one (0xfe9f). I think that one may be multiple devices reporting as the same ID. It will show up less than 1 meter away from multiple receivers constantly. At no time does any ID “settle” into an area, even overnight.

I guess the good news is that I got results; bad news is the results are generally useless so far. Obviously, I’m a little underwhelmed with the performance right now, but maybe some configuration changes will make the results useful.

What is the performance difference between “Active Scan” on and off? Should I re-flash using “verbose logging” mode? What tracking devices work best with this setup (Tile, Fitbit, Android phone, etc.)?

Thanks again for your help!

Copied from BLE monitor docs:

In active scan mode requests will be sent, which is most often not required, but slightly increases the sensor battery consumption. ‘Passive mode’ means that you are not sending any request to the sensor but you are just receiving the advertisements sent by the BLE devices.

Hey Ernst,

Thank you for the reply!

Does that mean there will be more devices detected in “active scan” mode? More accurate results? More details returned? The only thing the docs say will result is more battery consumption. Are there other drawbacks to “active scan” other than power consumption?

Thanks again!

Another quote from https://support.digitalmatter.com/support/solutions/articles/16000100684-active-vs-passive-bluetooth-scanning

Bluetooth scans can either be passive or active. When passively scanning, a device will only listen to Bluetooth devices, quietly collecting data about its surroundings. Active scanners respond to every device they hear from, asking if they have more data to send. The devices then respond with any “scan response” data they have been configured to send.

Generally, passive scans give you all the information you need and use less power than active scans, so are the best option. Active scans are only necessary if the Bluetooth device you are scanning for has been configured to send “scan response” data, you require said data, and the necessary integrations to collect that data have been implemented on the scanner.

So, if the device sends all info you need, there is no need to use active scan. Only some devices send additional data, when you use active scanning. (e.g. Govee sensors)

Ahh, got it. I’ll turn on “Active Scan” since mine are hard-wired instead of battery-powered.

Is there an advantage for “verbose logging”?

General update:

Turning on “Active Scan” increased the number of identified devices. I have also decreased the report distance from 3 meters to 2.5 meters because devices were showing up like this:

We’ll see how things look after running overnight.

Thanks again for your help!

I gave up. iPhone is changing all the time the address. So I can’t stick on 1 ID.
Project is great. Great potential !!! But I think not for iPhone users… :frowning:

2 Likes

Hi…

I am trying to setup ESpresence. However, I followed the video and it says to configure the BLE in the Home Assistant companion apps so as to set it up for iBeacon. I am using the latest companion on my iPhone apps with backend Home assistant 2022.3.5 version.

However, I can’t seems to locate the iBeacon setup on the companion apps at all. The place i look up this is from ‘configurations’ sub-menu → ‘Companion Apps’. Attached please see the items display in under the ‘sensors’ section of the companion apps :slight_smile:

I see that you have some iBeacon detected and wonder if you have setup the companion apps to transmit iBeacon signals for IOS devices.

im trying to work out what

sd:0xfe9f is so I can filter it out of my esp32 espresence as its noisy as hell

Ok, I figured this - it’s the Google Home speakers. So just filtering them out, as it’s useless to me.