Problems showing up new entities with MQTT Room (ESPresense)

Goodevening all!

Since it’s my first post here and before I start asking any questions I think it’s only polite that I introduce my intentions on here a bit. My name is Bryan, I’ve been playing around with home automation since 2017 where I got indulged with my first “brain” of the home. That was Home Assistant. I’ve switched around towards solely NodeRED and OpenHAB3 since HA back in the day was a great product, but it was incredibly difficult to configure (too much YAML, I don’t mind making my hands dirty but Home Automation should be fun and I don’t always feel like coding :wink:). I’ve taken the plunge back into Home Assistant in 2022, seeing how mature it became and so much more user friendly. I’m glad to be part of the community and hope that I, in the future will also be able to provide some answers to questions asked here!

To get to my question. I’ve been tinkering around with ESPresense a bit, since I was intrigued by BLE and the multiple usecases I could use this for. As a very simple start I wanted to spin-up my ESPresense instance and verify if I would be able to let my iPhone be shown in Home Assistant.

I’ve done the installation as per the instructions on the ESPresense website. I was able to get my ESP connected towards my Mosquitto broker succesfully, the ESPresense base station also showed up in Home Assistant. So far so good! My connectivity from Home Assistant towards my MQTT broker is working correctly. When I came to the part of configuring my sensors, however things started going downhill a bit. Currently I have the following configuration in my configuration.yaml file:

# MQTT ESPresense Devices
 sensor:
   - platform: mqtt_room
     device_id: "iphone"
     name: "iphone"
     state_topic: "espresense/devices/iphone"
     timeout: 10
     away_timeout: 120

When restarting Home Assistant, I don’t see any new entities show up. I’ve thus decided to troubleshoot a bit further. What I did was run mosquitto_sub from a remote PC towards my mosquitto broker and I subscribed to the topic espresense/rooms/#. I’ve noticed that I’m correctly finding my iphone and the distance is being reported correctly as can be seen in this screenshot (some things blurred out for privacy reasons).

I did some googling, and on the Home Assistant - MQTT Room integration I’ve noticed that the configuration was slightly different. The state topic there was espresense/rooms. So I tried that, bud sadly enough I was unable to see any entities show up in Home Assistant. I’ve used MQTT Explorer as well just to verify that I’m effectively seeing all the state updates correctly. This was the case.

I’m curious where things might be going wrong and was hoping any of you had any experience before. I’ve read in a forum post here that someone had the sensor: configuration block twice. I as far as I know do not have this within my configuration.yaml file.

Any help is very much appreciated!

For iPhones you will need to use an irk for “device_id”. You currently have it set to “iphone”, but nothing will have this id (EDIT: Actually maybe you can call it this on the devices page, but you still need to use irk for iphones). You might also want to consider setting filtering in each Espresense instance to only include your tracked devices rather than the neighbours etc (enter in the format “irk:the-rk-goes-here”).

I have set the “state_topic” to “espresense/rooms”. I believe if you want to use device it needs to be in the format “espresense/device/device_id”. The documentation only shows this format, and I can’t remember why I went with “espresense/rooms”, but it works.

Also include a “unqiue_id” so you can update details.

I’m having the same problem - MQTT discovers the ESPresense base station just fine, and I can see the beacons in MQTT Explorer, but the sensors don’t show up anywhere.

My config looks like this:

sensor:
  - platform: mqtt_room
    device_id: "irk:SECRET1"
    name: "Eric's iPhone BLE"
    state_topic: "espresense/devices/irk:SECRET1"
    timeout: 5
    away_timeout: 120

  - platform: mqtt_room
    device_id: "irk:SECRET2"
    name: "Eric's iPad BLE"
    state_topic: "espresense/rooms"
    timeout: 5
    away_timeout: 129

  - platform: mqtt_room
    device_id: "irk:SECRET3"
    name: "Roman's iPad BLE"
    state_topic: "espresense/rooms"
    timeout: 10
    away_timeout: 120

  - platform: mqtt_room
    device_id: "tile:TILEID2"
    name: "Checkbook Tile"
    state_topic: "espresense/rooms"
    timeout: 10
    away_timeout: 120

  - platform: mqtt_room
    device_id: "tile:TILEID"
    name: "Car Keys Tile"
    state_topic: "espresense/devices/tile:TILEID"
    timeout: 10
    away_timeout: 120

I’ve replaced the IRKs with macros for secrecy. The docs are a bit confusing for the value for state_topic; some docs say to use espresence/rooms, others say to use espresence/device/id, but, as far as I can tell, NONE of these work.

Also, for clarity: All these nodes are visible in MQTT explorer.

What am I doing wrong?

I’ve the same problem. I cut and pasted the topic addresses from MQTT explorer incase i was doing something wrong, i even set the name, device_id, everything to the irk reference incase it was looking at this in an odd way, but no information.
when a new device is discovered this is added to homeassistant and then immediately goes off line, which i assume is deliberate to register the device_tracker.
its as if home assistant can’t look in the espresense/devices/xxxx topic?
it makes no sense to point at the /rooms/ topic as the device does not show under that topic?
i’ve tried al lthe options i can think of and i just can’t solve it.

So I did eventually get things working:

  • Reduce distance settings on the beacons so they don’t overlap
  • Use espresence/rooms topic
  • Most importantly, FULL restart of HA after updating sensor definitions. Reloading the YAML is not sufficient.

Thanks Eric,

Yes that was what i found - i was changing options with a yaml reload not a full reboot - hence it not having any effect!
All working great!

So is this helping for all of you guys?
Because I’ve got the same problem but without this solution working.
I had quite a hard time setting this up the first time (so esp presence + mqtt sensor) but then it worked.
After a while I noticed that the sensor stopped working.
Because there were quite some updates in the meantime I figured that something with the esp presence would have been the cause.
So I set this up again and had again a hard time to get it working.
At that point I realized that my sensor syntax from the first time was correct (because there are quite some variants to be found in the web) and that no update seemed to have been the cause for the stopping.
Ok whatever, it worked again.
Unfortunately not for very long.
This time I was smarter and checked everything thoroughly before and saw, that the esp presence is working. What is not working, is that the sensor get’s any data.
So what could be the cause for this? I don’t think that there was a change in the way the sensor syntax is supposed to be but obviously there is a connection problem between the mqtt server and the esp.

Are you running the v3.3.1 ESPresense firmware? There was an (IMO) breaking change in the 3.3 firmware where the firmware no longer updates the MQTT topic espresense/rooms - and now you must use the topic espresense/devices.

So, my sensor definitions look like this:

  - platform: mqtt_room
    device_id: "my_device"
    name: "My Device"
    state_topic: "espresense/devices/my_device"
    timeout: 5
    away_timeout: 120

Watching this closely. I’ve been fighting with this, and it does seem like everything changed in late 2023. I may just start a post of my own, because it seems like all the posts and information are different now, and a lot of searching has come up empty.

Hi,

Was there an up to date answer for this issue as I’m having what looks like a similar problem.

Steve …

Same here, tried every configuration out there, but no new entity appears. What else has changed since 2023?

Just throwing out some ideas here as you haven’t discussed what debugging you’ve done…

I’ve been using this flawlessly and got caught out by the shift in topic for ‘state_topic’ but rectified it based on the above.

  1. Have you logged into an espresense and viewed devices to confirm IRK still the same/exists?
  2. Have you thought about registering an alias on espresense for iphone by connecting directly via bluetooth using the enroll function on the espresense and coding the alias in HA?
  3. Have you checked the actual espresense topic using mqtt explorer (or smiillar)?

So for me, unfortunately, the problem is still with me. Today, for example, even the complete restart does not help anymore.
The funny thing is that of my four sensors there is one that doesn’t cause any problems. However, the config is identical (except ID and IRK). So I’m starting to get really confused

Here is the sensor configuration which works:

- platform: mqtt_room
  device_id: "phone:XXXXXXXX"
  name: 'Marco iPhone (ESP)'
  state_topic: 'espresense/devices/phone:XXXXXXXX'
  timeout: 10
  away_timeout: 120

I know this is an old thread but are you putting the ID’s in espresense to track? I use Android and I know there are some difference but in the companion app it creates a sudo BT address under sensors and that’s the ID I use. Not really seeing any point in masking it because it’s not real (per say) BT MAC and an option the only broadcast when you’re on your home network but iOS may be different. After turning on the BLE tracker sensor everything works for me.There is an iBeacon integration also, not sure what it’s for though. I removed “Distance” from the screenshot below. I don’t know how that got there probably when I was trying to set it up

HA Settings > companion app > sensors (Android only)

- platform: mqtt_room
  #device_id: 'iBeacon:d1db1ba1-9201-4a7a-9822-xxxxxxxxxxxxx-100-1'
  device_id: 'iBeacon:afee576d-8da0-42e8-8e76-xxxxxxxxxx-100-40004'
  name: 'my phone location'
  unique_id: myphoneid
  #friendly_name: 'my phone'
  state_topic: "espresense/devices/iBeacon:xxxxxxxx-8da0-xxxxxxxxxxxxxx-8-xxxxxx" 
  timeout: 10
  away_timeout: 120


EDIT: realized my friend had an iPhone so only one that showed up in espresense. It needs to be added to 'Counting" in espresense at a minimum After adding it and rebooting home assistant it showed up right away. No sensor, just use the apple:xxxxx-x value that shows up in espresense . IRK 32 key goes into " resolving keys" in espresense, not counting. According to the documentation you can hit enroll in espresense web UI then accept the connection on your phone or iPad but 32 character key specified is probably the better method. I probably did the manual way using Apple:xxxxx-x

Add the output (which should be 32 characters) to the ‘Known BLE identity resolving keys’ section of the ESPresence configuration.