Espresense device id - how to get them?

Hi there

Yesterday I stumbled across espresense (https://espresense.com) and love it! I installed it testwise on a spare ESP32 and the installation went fine. I struggled with the device_id and noticed that you cant put in the bluetooth MAC-address (as it changes) After some research here and in the internet I read that I have to put in the apple-specific ID like apple:XXX:XX-X. Below you can find an example of my config.yaml with a sensor.

my question right now is: how can I retrieve the device_id in an easy way? Would love to hear your feedback as it seems that a lot of people struggle with the devide_id.

I used Node-RED and listened to a mqtt-topic to have the devices listed. as you can see its a bunch of data and I could only evaluate my phone by moving away from the ESP and check if the distance changes, not very convenient.

sensor:
  - platform: mqtt_room
    name: "iPhone BT Andreas"
    device_id: "apple:1006:10-8"
    state_topic: "espresense/rooms"
    timeout: 5
    away_timeout: 120

Kind regards

Andrew

Bingo ! I only discovered espresence yesterday too after watching this The BEST Smart Home Room Presence Detection I've Tried! - YouTube

  • Like you I’m having difficulty deciphering the ids so I think what I’m going to do later today is to flash another ESP32 and set it up in another room

  • Monitor the room topics like you’re doing …

mosquitto_sub -h 192.168.1.1 -i presence-information -v -t "espresense/rooms/+" | grep 'suspectedid'
  • See if the device jumps between rooms when it is physically moved between the ESP32s

Wish me luck !

EDIT: as per the video I also use the mobile nRF app but it’s not making life that much easier

1 Like

hehe, I watched exactly the same video! actually found another one which explains the process of finding the ids a bit better: Track Objects Inside Your House with BLE // ESPresense & Home Assistant - YouTube

have a look at it, it might help :wink:

1 Like

did you get it working _dev_null?

I noticed that when I switch between two sensors (lets say from the livingroom to the office) it takes around 30 secs until the state in HA switch from one room to the to other. I use an iPhone 12 as a beacon. They are configured that they only report 2 meters of distance while the sensor are around 5 meters away from each other.

Do others have the same issues or am I doing something wrong or have to adjust something?

I do have a Zigbee-network on channel 25 as well as 2.4Ghz and 5Ghz Wifi in place.

Hi Andrew,

Unfortunately I’ve not had time to revisit this project, I even bought a new esp32 with an antenna but again not had the chance to implement.

The way things are looking this one is on the back burner for now :o

Surely it’ll need tinkering with dbm sensitivity and what not and I simply don’t have the time for that

Good luck mate

I’ve got a similar issue, I added details to an existing ticket on github:

1 Like

Hi
just found this and joined to post.
I plugged the esp32 into my laptop and connected with the espresence web terminal at Web Terminal | ESPresense, held the esp32 next to my phone and toggled bluetooth on and off, each time a light flashed on the esp32 and a new device was reported with a different mac but same id, used the id in the yaml config and distance is being reported.

You’ve obviously got yours sorted but hopefully this’ll help others.

Kind regards
Roy

No, unfortunately its pretty much garbage for iPhones. I have the same issue Phones right next to the ESP and no such device with the same Mac address.

One thing you can try is the Room Assistant app. But this is also rubbish for me, sensor more often then not shows device as not_home

Oh, and just to be clear, I blame iPhones for how troublesome this is, not the dev. I think hes making the best out of an evil corpo lol

I’ve gotten it working with both my iphone and watch and though it isn’t as responsive as I would like, it does work; however!!! I can only get it to essentially track 1 iphone or 1 of a specific model. The problem is my wife and I have the same iphone model and I have not been able to get Espresense to differentiate between the two. If one is move, they both are updated to the same distance. it’s kind of freaky as it looks like someone is jumping back and forth between two rooms. The problem is it sees both by the same ID: apple:iphone11-2 which comes from the model name. Even installing a bluetooth tracker didn’t help. So for now HA tracks room presence for me by my apple watch and my wife by her phone.

hi there

thanks for all the comments. actually I switched to https://www.room-assistant.io/ which (in my opinion) works better and even has an app for iOS, check it out :wink:

I installed it on a Raspberry Zero 2W

I started off in that direction until I saw the Raspberry Zero 2W going for $94 on Amazon. So I opted for Espresense with D1 mini esp32s which were 3 for under $20. Maybe when prices get back to normal.

yeah, Raspi became very rare and expensive. I recommend to regularly check this website: rpilocator - Find Raspberry Pi Computers in Stock It tracks which models are available at the official resellers, I had the luck to get some 2W for around 20$ each.

Hi all

It is possible to get the unique identity for Apple iPhone and Watches. The documentation does exist on the ESPresense website, it’s not overly obviously and it’s a bit of a pickle initially but seems to work perfectly well for my setup now that I followed the instructions:

Basically, you need to identify the IRK (Identity Resolving Key) for your Apple device. Note, that if you use the auto option for the phone, the ESPresense will start broadcasting to MQTT using the name of the device you gave when you “Enrol” it. Whilst this is easy, it really isn’t ideal, as if you run multiple ESP’s, you need to enrol the same device on every ESP with the same name for it to work. Best to get the IRK, either using the Enrol option, or the Keychain Access option (works for phones as well as watches) and then add the IRK’s to the ESP configuration on each ESP. The MQTT output will then use the IRK which will match on all ESP’s and the HASS config.yaml can be set to the IRK meaning it will be picked up from the same IRK from all ESP’s. Hope that makes sense.

3 Likes

I’ve been staring at this for so long I’m screen blind so, whilst I’m sure you did a banner job of explaining, can you show a sample of your config that made this work, please?

I’m a very visual learner at this point lol

1 Like

Hi, I’ll try!!!

So for an iPhone (different practice for the watch)…

Open the web ui for your Espresense device, change the default page to http://your_espresense_ipaddress/ui. This will show a basic page as follows:

Enter the device name (I don’t think it really matters as we’re going to drop this later - in my example here I have used “MyNewDevice1”) and press enroll.

Now take your iPhone, goto Bluetooth settings and join the Espresense device (obviously you need to be in range!). Make sure that it pairs successfully, if it doesn’t, turn the bluetooth off and back on again on your device until you get a successful pair. Note that your phone will not stay connected to the Espresense for long, even after a successful pair, do not be concerned with that.

When this is done, switch to the Fingerprints link in the left menu and you should see your device show using the name you entered in the Enroll stage.

Next, to get the IRK value (not shown in the fingerprint screen), you will need to take a look at the MQTT data your Espresense is publishing. To do this, I use an app called MQTTExplorer to view all the MQTT data being published to the MQTT broker (super handy tool if you haven’t already discovered it). Under the node espresense > settings you will find an irk:your_irk_value_here entry. To confirm its the right device, if you expand it, you will find a config entry with the device name you used during the first Enroll step.

Now that you have the irk, you need to add it to your HA configuration.yaml as a sensor:

The device_id is where you put the IRK value, you need to enter it as follows (note that I have mine extracted to the secrets file which is a good practice):

device_id: "irk:abc123etc"

You should also then visit the default config page on your Espresense device to populate the configuration with the known IRK number. Note the format here is without any irk: prefix, just the value and for multiple irk values, space separate them. Ideally, register all your devices in one session on a single Espresense device and add all the IRK values to one, and then copy and paste the entire string into all your other Espresense device configs.

So the next part I found a bit fickle. But because the device is “Enrolled” with whatever name you used, this is what is published to MQTT (initially at least), not the IRK number… :frowning:

To resolve this, I delete the espresense/settings topic on my MQTT broker and restart the espresense device that I did all the enrolment on. There’s a bit of a timing knack to this as they seem to re-populate from each other. I would have thought that this means you should be able to not have to use the IRK values in HA at all, and just use the enrolment names, but I found that this doesn’t work across multiple Espresense devices, whereas using the IRK values does. YMMV

Hopefully you have the MQTT broker installed in HA already, which should pick up these entries after a restart possibly.

You should also have a sensor entity in HA for the device you enrolled.

And then if you look at the state history it will show where it was detected.

You can then use the sensor state for automations / cards etc as you wish.

For Apple Watch’s, the process for retrieving the IRK value requires that you use a computer to access your iCloud Keychain data, but once you have the IRK value, the rest of the process is identical.

I hope that helps.

17 Likes

This is a brilliant explanation and with it I nailed it. Thanks very much - this really should be pinned somewhere.

1 Like

No worries, glad it worked and that I could put something back into the community. I’ve picked up so much from here myself.

To be honest, it should probably be pinned on the espresense web site, the documentation requires a little bit of improvement IMO, but we can’t have everything for free, so it’s good to help each other where we can! My bit of kindness for the weekend. :slight_smile:

4 Likes

Big thanks from my side! Your post is gold.

1 Like

I am trying your steps, but I do not see my device name under Fingerprints after a successful pair. I do see the irk under settings in mqtt explorer, but the irk id does not show under devices in mqtt explorer.

So just to be clear, you did type a device name (doesn’t matter what) in the text box next to the Enroll button before pressing the button? This is the name you should be looking for in the Fingerprints list, not your actual device name.