Using MAC to differentiate between identical tags

I have some BLE tags that have the same UUID. So I need to use the MAC to differensiate between them. I found a year old post by @callumw here that indicated that it was possible by using this format:

# MQTT_Room ESP32
- platform: mqtt_room
  name: "Fitbit 1"
  unique_id: 3ca1983f-941a-494a-b03a-b682661aaa23
  device_id: known:651wdw651w51
  state_topic: "espresense/rooms"
  timeout: 5
  away_timeout: 120
- platform: mqtt_room
  name: "Fitbit 2"
  unique_id: 150d2e41-0f1b-413a-819f-b4f497e01d90
  device_id: known:87fw79wf9we7
  state_topic: "espresense/rooms"
  timeout: 5
  away_timeout: 120

But I can’t get it to work. I have set it up without the timeout, but that shouldn’t matter since that’s optional. This is how it looks here:

  - platform: mqtt_room
    unique_id: iBeacon:fda50693-a4e2-4fb1-afcf-c6eb07647825-1-2
    device_id: known:00000000000c
    state_topic: espresense/rooms
    name: 'Mastiff's keys'
    away_timeout: 60

(The UUID is a standard one that all these ships with, only the MAC is different, and I tried both with and without the “iBeacon:”). But in the sensors part of the UI the entry for Mastiff’s keys is always not_home. Am I doing something very wrong here, or is this because of a change in how ESPresense sends stuff? I have set the MAC as a known MAC in ESPresense, and I get messages like this in Node-RED:

espresense/devices/known:00000000000c/office
{"mac":"00000000000c","id":"known:00000000000c","idType":210,"rssi@1m":-40,"rssi":-68,"raw":6.31,"distance":6.48,"var":1.4,"int":2781}

That doesn’t look right to me…

Mine:

  - platform: mqtt_room
    device_id: "iBeacon:b34fee75-e70e-4a94-bc5e-89aec52fb724-100-1"
    name: 'BLE-sPhone'
    state_topic: 'espresense/devices/iBeacon:b34fee75-e70e-4a94-bc5e-89aec52fb724-100-1'
    timeout: 5
    away_timeout: 120

To me (and I may be wrong too), I think you need to swap unique_id and device_id ? And I’m using espresence/devices as the MQTT Topic

@AutoT Thanks for putting me on the right track! I changed the topic, and that didn’t help. I added timeout as well. Then I changed the device_id on both to “known:” and the MAC, and used the same in the state topic, and bingo! Working! :grin: :+1: So when using the MAC and setting that as known in the ESPresenses nodes both the device_id and the state topic needs to use that. This is the working version:

  - platform: mqtt_room
    device_id: "known:000000000000"
    state_topic: espresense/devices/known:000000000000
    name: 'Mastiff's keys'
    timeout: 5
    away_timeout: 60

Out of curiosity, what tags are you using? Personally I am quite fond of BlueCharmBeacons. They are highly configurable and come in a number of configurations to meet your needs. The person who sells them is also part of the community and is very helpful if you have questions.

Yeah, I know about them. The problem is that the shipping and custom fee to Norway more than doubles the price, close to tripling it if I remember correctly. I’m using these from Ali:

https://www.aliexpress.com/item/1005006305612806.html

I bought two first to see if I could get them working, and now that I have them up and running I’ll buy the rest that I need (guests and so on).

Ya, that is a common problem I hear. The link you sent, it only took 3 minutes of reading the specifications and directions to see that it specifically tells you what the default UUID, min, and max values that come on them. Followed by those little details is instructions on how to change the UUID, min, max values specifically for anyone who buys multiples and needs to give them unique UUID’s to distinguish between each one.

I’d really suggest making a habit of reading that stuff. It’ll save you from buying junk that wont work or wasting time solving problems that never should have needed solved.

@Fallingaway24 Thank you for the condescending tone and information, implying (or saying outright) that I’m either to lazy or to dumb to read what I buy. :crazy_face:

Ok, now that I have gotten that off my chest, I did not write it in the first post because I didn’t think it was relevant, but I did read it before I bought them. When I got them I tried to download the app from the Baidu-link, and I could not get it working. And no other Android app I tried will connect to the beacons to change info. I do know that the iPhone app works (from a PM conversation with another member who has used the same beacons), but I literally don’t know one person who has an iPhone. I think they are more common in big cities, everybody I know here in my small town uses Android. So since I knew that the MAC would work if I only found the right way to do it, I spent maybe half an hour messing around before I posted this thread and 15-20 minutes after the first answer and it now works 100 % on both my locations.

2 Likes

That was a bit condescending of me and that was wrong, I apologize for that. In my experience, its usually a good bet that someone didnt read the specs or instructions before posting questions.

Ya, unfortunately those apps can be hit and miss especially when using cheaper products from China. You got it working so, I guess that is the important thing.

Incase your interestes, I also find this BT presense useful. Its not as good as Espresence but, if your in a predicament and need to use 1 esp32 and not a second one just for Espresence.

It allows me to work out BT beacon distance from closest beacon but you have to manually create the logoc forn which room it shows in. Here I have distance, beacon battery level, and a sensor for the beacons that use a button or have other sensors. You can extract that data and use it as well as still have full use of your esp32 unlike when using Espresence.


Thank you, I appreciate the apology, and accept it. :+1: I have a few ESP32’s, so I have three of them in the house so it covers all of it. I have tried with ESPHome, but using the BLE option there turned out to create very bad problems for the wifi. With the price of ESP32’s from Aliexpress it was better just to let ESPHome do the other stuff, like sensors and relays, and have ESPresense for the room detectors. But to each his own, of course! :grin:

Very true, that is an option. For me though, once I hit around 30ish esp nodes it also started having very negative effects on my wifi and fixed it by consolidating nodes. In my experience, once people get into esp’s and diy projects they tend to get addicted and its not hard to hit 20÷ nodes and thats why i made that suggestion.

Incase you didnt know or havnt tried, Espresence does handle some sensors and other things. It actually does it really well and offers some flexibility so people can consolidate some things.

@Fallingaway24 Yeah, it’s really easy to get carried away. In my 24 foot boat I have 10, but they are all completely full, with relays and sensors, so there’s nothing to consolidate there. I’m slowly making automations and connecting them to stuff, so in the end I should be able to control everything but the steering wheel, gas and gear on remove! :grin: I haven’t tried the sensors, but there is one that does outside temp in a shady place under the cabin with a three wire sensor that I could try to consolidate with the ESPresense in the same room. :+1:

You say its a 24’ boat and im invited Saturday because, we’re Esphome Anonymous best friends??:face_with_peeking_eye:

A boat sounds like something you could really go to town with by adding esp’s and improving things or automating them. Im a little jealous…

If i remember correctly it can use dht-11, dht-22 and maybe others, id have to go look again and refresh my memory. It does allow for white/monochromatic lights as well as RBG led’s too.

If you dont mind, could you share some pics or details about what all youve done with your boat? Its very interesting and refreshing hearing about somethin other than another home project that lacks any new creativity and is a copy from elsewhere.

If you can take the heavy metal from the stereo while fishing, you’re welcome! :grin:

Most of the stuff is hidden inside, but basically I have two Pi’s, one Pi 4 that runs Hass, Node-RED, J.River Media center (2 TB SSD with music), SignalK (which sends info from the plotter and engine interface to Hass) and a few other things. This Pi is connected to the cabin’s wifi by an Asus USB AC on the roof and works as an access point, with output on LAN. The other is a Pi 3B, which has an extra GPS for when the plotter is turned off, and it acts as an access point with input from the other Pi on LAN and output on a Realtek N wifi dongle, which all the ESP’s and the phone I use as a display on the forward steering position (where I pull the crawfish pots and other pots).

The ESPs are used to turn on and off stuff (lights, stereo and so on and so on), and one of my best uses is on stormy nights during the winter. I can turn on the lights on the roof and see that the boat does not need to be secured better. All the electronics is inside waterproof and pretty airtight boxes of this type (this is for the windshield wiper and the horn, with piezo switches, so I can have interval wiper too):

I’m working on making a custom frame for a 10" tablet inside a waterproof bag, and this is the main screen for that:

The three bottom icons go to other screens with lights, windshield wiper and control over tilt and jack plate (a vertical plate that moves the engine up and down). I have limit switches and other safety devices that makes sure the enigne isn’t tilted too high when running.

This is the boat itself. The long board on the port side is for lining up crawfish pots, and then I just drive them out the rear. The green ting close to the front is the power block, which hauls my crawfish pots from a depth of 100 meters or so. You can’t see the front JBL 6x9 marine speakers, but they are up over the windscreen. There’s one pair under the roof, just under the lights. You can see one of the two 12" subs on the side of the storage, there’s another one on the other side. one ESP is under the hatch in the front, and a cabled remote for the stereo is besides the front steering wheel.

This is the info screen i have on a Ram Mount above the front steering wheel, with all the info I need there, like depth, speed, time, water temp, engine RPM, fuel usage and tilt, voltage on the front and rear battery. The engine info is dashes because I turned on the mains power to take this screenshot but I can’t yet turn on the engine by remote, I have a few more relays to connect first.

Some day I’ll do a full writeup of the boat, but that will have to wait until everything works. I retire in four years, maybe I can managed that then… :rofl:

Oh, here’s a shot from today when fishing, which shows how the phone is mounted. The seagull is not mounted…

For all that stumble upon this thread and don’t get it to work as described above - before the device will be available as “known:XXXXX” with the mac adress behind the colon, you first have to add the mac address (without colons) to the list of known mac addresses for the espresense nodes! Then (and only then), they will be reported as “known:XXXXX” via MQTT and Home Assistant can recognize them using the JSON snippet shown in the SOLUTION post: Using MAC to differentiate between identical tags - #3 by Mastiff

1 Like