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.