Understanding BLE trackers

I’ll have a read, thanks. This is my first foray into ESPHOME and I’m very green. I just need to learn how to look for a certain string within that Adv data, I imagine.

Thank you,

What you expect to have in that string?

Sorry, what I mean is that I don’t fully understand what the name of the string is that I’m looking for and how I can search for a sub-string within it.
I realise that this probably sounds dense, but this is my first attempt at anything like this.

Don’t worry. I just don’t understand what you are looking for. An example?

Yes, that’s it. I need to understand what code I enter to search the relevant data stream and then how I tell that code what to actually search for (as in: I assume that I don’t need to include the wrong string in the search, but a unique part of it).

You need to know where that relevant data is. And what form of data.
Bytes can represent one ascii letter, or dec number or 8 individual bits. Sometimes those bytes are separated to represent two individual numbers.
There’s no generic way of reading whatever message.

Have a look how I extract temp and humidity data from specific known bytes.
Humidity is extracted from eleventh byte, temp integral from tenth byte and decimals from ninth byte. There’s some bitmasking also.
No way you can find those data if you don’t know what/where to look for.

on_ble_manufacturer_data_advertise:
    - manufacturer_id: '0969'
      then:
        - lambda: |-
            float humidity = x[10] & 0x7F;
            float temp = (x[8] & 0x0F) * 0.1 + (x[9] & 0x7F);
            if ((x[9] & 0x80) == 0){
              temp = -temp;
              }

I gotta give you props for your level of understanding this. Everytime I try to learn this, I quickly realize that smashing my fingernails with a hammer is more preferable… I do appreciate all of you folks that do understand it and can help out thogh.

I’m not a bit manipulator either. Having hard time when I need to break and join bytes!
To dig that temp sign +/- from single bit in tenth byte made me loose my hair.

I like learning a lot of stuff but not that and I cant even force myself, its unbearable lol.

I didnt catch the reason why OP doesnt just use something like Bermuda or Espresence? Pulling in BT beacon temp data cant be that big of a deal.

1 Like

Two reasons, really:

  1. This was partly a learning exercise for ESPHOME
  2. I didn’t know about Bermuda until this thread - and have now installed it.

Annoyingly, I’ve had BLE tracking working absolutely fine natively in HA for months and then it suddenly stopped working completely. I think it was a HAOS update which broke things. So, I thought that this would be a good way to jump into ESPHOME.

Ok, that mostly makes sense, I think.

Except… where did you get the manufacturer_id from? What would be the equivalent in my case?

Right but, only tracking in HA is really no different than using presence based on devices connecting to wifi and showing Home/Away or from gps data showing the dame thing. At least for me, presence detection is more than home/away. Its home, which room everyone and their devices are in, their location in that room if something is lost and needs found and its pet tracking to notify me if my dog gets out of the fence. Im not sure if thats your end goal but, to man6 people presence is simply home/away and IMO that isnt extremely useful information.

It’s part of the broadcast, 2 bytes but in reverse order. Yours is 0075, if I remember correctly location.

[09:35:06][VV][esp32_ble_tracker:481]: Adv data:02.01.02.0E.FF.75.00.01.00.02.00.01.03.`

Anyway, try Nordic nRF Connect app. It’s helping to understand packets and devices you have nearby.

Just for fun; I had problem to reach one of my sensor quite close to Esphome, but at the same time I was able to read my neighbors Xiaomi toothbrush trough 35cm brick wall.

There are many different presence detection solutions out there.

I use Monitor as it can track both BLE and traditional Bluetooth devices in a way that is kinder to your 2.4ghz network.

I also use ESPHome nodes for recieving some BLE sensors.

Home/away is fine for me, room based automations I can cover ok with motion sensors etc.

As far as I understood OP wants to detect some data from broadcast, not just detect presence…?

My reading of OP was that they wanted to track a device with a randomised MAC, which transmitted some fixed manufacturer data they were hoping to leverage? Not sensor data as such?

And I replied in post 2.
After that I wasn’t able to follow what OP is looking for…

1 Like

I’m also just trying to broaden out the topic a bit.

I think when you start with presence detection, you can get fixated on specific devices, solutions or aspects of it. Or you don’t even really know your requirements.

Last time I checked (quite a few years ago), room based tracking was an estimate at best (twist your arm or walk in front of obstruction and now the rssi is stronger in another room etc).

Many people end up with hybrid solutions for more localised detection: Bed occupancy sensors, mmwave, PIR, phone is charging etc. I even use a time of flight sensor at my desk.

Then there’s ping, GPS etc etc…

So I think it’s good to read up a fair bit on the topic before committing to one solution too much. Unless you’re happy just tinkering with whatever to start learning.

This all said, I don’t have a view to the best solution for the more immediate use case of tracking device with randomised mac using manufacturer data.

I’d just like to thank everyone for their help. I think that I have enough to get this working now, albeit I clearly need to do a lot more reading.

I have installed the Bermuda integration and that seems to have resolved the immediate problem (HA native BLE tracking simply stopping dead). However, I will also look at using ESPHOME for tracking my watch as (it seems) as if Bermuda might struggle with that.

My immediate requirement was to resurrect a number of automations which trigger when my granddaughter is with us (turning off various devices and arming presence sensors etc). These had been working very well based upon a tracker in her changing bag, but stopped when HA stopped working in this regard.

Wanting to track my watch was a separate requirement which I’d wanted to pursue for some time.

Thank you everyone for your responses.

1 Like