i’m doing some experiments with an ESP32 and room presence and struggel to set up the sensor in home assistant right.
Everthing is setup, ESPresense makes a mqtt room topic in espresense/rooms. In my case it is ‘arbeitszimmer’. In the topic i can see the json with the id of the ha companion app.
(arbeitszimmer = {“id”:“iBeacon:8f3328a6-eacc-4f4a-8219-4bf04990b1b0-100-1”,“rssi”:"-60" and so on}
As i read in the docs the following sensor should be used:
device_id should be the uuid without “-” and at the end -major-minor, -100-1 in my case. But the sensor is always ‘not_home’ and the distance is null, i think something is not right with my configuration.
Maybe anybody has a hint what i am doing wrong?
I don’t use ESPresense for my room presence but in HA mqtt_room I use the Companion App Device Name as device_id that’s also what’s published in the mqtt’s id field. So I’m thinking you need to include the iBeason: in your device_id
With all ‘-’ characters exactly whats in the mqtt id field. (seems the docs there are a little bit outdated)
Thank you very much for pointing me in the direction!
Sorry to wake this zombie from the dead, but I’m stuck on this. And it’s slightly embarassing, since I think I should be able to figurei it out myself. But I’m not… Here’s the message I get:
I have tried using the id string as the id in my config.yaml, and I have tried using the disc, whatever that is. But none of them work. What would be the correct thing to use here?
Edit: Here’s my sensor as it is now:
sensor:
- platform: mqtt_room
device_id: msft:cdp:0902
name: Tor
state_topic: espresense/rooms/boden
But it’s weird, the MQTT messages that I can see in Node-RED (just a simple debug node) shows no difference in distance when I move the phone. Maybe that’s not my phone after all…
Thanks for answering! I have tried that, both with only the short device ID and the long disc as well, split by a dash. But I just discovered that it’s my Surface Pro it’s reading, not my phone. Which is why there was no change in distance. I don’t get anything from my phone, weirdly enough, even if that’s just as close.
Yes, and I have it 50 centimeters from the ESP at the moment. Latency set to low and power to low. I’m going to use this for my door, if I get it working, so I only want it to notice the phone when it’s within a meter from the door.
I have the same use thing, the internal ble transmitter works perfect for me. To check where the problem is, have you tried another app (beacon scope or beacon simulator for android) to send the beacons or do you have another device where you can check with the same apps the phone is sending beacons?
Getting closer, it seems to be a “compound fracture”. My damned Huawei had killed the beacon the second the companion app wasn’t foreground. That’s the one thing I hate about the phone, it’s totally crazy about power saving. I made a quick flow in Node-RED (which I’m more accustomed to programming in) to format the input to what I need, and I now get these in:
The distance is off by 90 centimeters, since the phone is about 40 cm from the ESP, but that’s for later tweaking, when I actually get it working. I also changed the “state_topic” since it seems like it’s differently formatted from yours. You have 'espresense/rooms', while my messages are formatted like this:
So decices after espresense, not the room. The name of the room (boden is the shed by the door, outside, so I won’t get a signal and unlock the door every time I pass by the door on my way to the bathroom…) is the last thing in the topic. So that should indicate that this ought to work in my configuration.yaml:
But when I look in the ESPresense device (not the sensor) in debugging and check the topics received, there is no espresense/devices there at all. Only a bunch of other topics, like max distance, status and so on. I’m guessing that in your setup you see a message with the device in it, right?
Wow, suddenly it worked! I see the room where the phone is! The last piece of the puzzle was to change back to epresense/rooms It seems that what Node-RED gets and what Homeassistant reads are two different things. Thanks for your help!
The only weird thing is that if I move the phone from one side of the desk to the other, ESPresense counts slowly down over a minute or two, instead of showing the change quickly. But maybe that’s how it’s meant to be?
Final problem is that it seems the ESP looses connetion to my network quite frequently. I need to see if it’s something with my network being an Asus AI mesh, I have a few routers that I’m not using at the moment, so I guess I can repurpose one of them.
Just checked it here, the distance counts down also (didn’t noticed it before), i think espresense uses an average of the distances and the time, so i think also it’s the way it’s meant to be.
As i am using this only one moment of the day (when i arrive home ble transmitter goes on and when i am in my house the ble transmitter turns off, it should just recognize me when i am in front of the door) i cannot say if it is connected all the time, but i works for several weeks and was rock stable when it is used. I am using a mesh of fritzbox.
Glad you could solve it!
Sounds like the way I’m going to use it, only it should unlock the door when I get home and when my wife gets home. With three-four times walking the dog, she going to work (I’m working at home and have been for 29 years as a translator) and other trips out it is a bunch of times, but it shouldn’t be a problem. So I just need to fix this wifi problem. Maybe I’ll just put a Pi (I have a bunch of old 3B laying around that aren’t in use) as a wifi access point, with a LAN-cable connecting it to the mesh wifi.
Edit: It seems like the ESPresense is confused by the wifi, yeah. I have three routers that are “visible” where the device is, and it sees all the three networks, but it has to bind to one of them. I think it’s an annoying tendency to use mac of the router, not just the SSID.
How long does it take until you are registered? I get from 5 seconds and up to 15 with Beacon Scope set to high power and 10 mHz. 5 seconds is OK, but 15 is too long, it’s faster to use the tag to open the code lock.
Between activating the transmitter and changing the sensor from not_home to home it’s about 1-2 seconds. Tested indoor with 1 Wall and 2M between the phone and the esp and in the garden with 1 glass door and one room door closed 7M away.
I also have low latency (10Hz, not mHz ) and high transmitting power enabled.
If you are using it with enabling (and disabling) by notification command you have to use:
priority: high
Otherwise it can take minutes until the transmitter is activated.
This is my automation to enable the transmitter when i get near my home:
Hz, mHz, what’s the difference? Only a million or so… But activating the transmitter? Do you mean in the Hass companion app? Because I stopped using that since my Huawei insisted on turning off the beacon even if I set it to not be optimized. So I’m running Beacon Scope set to high transmit power, 10 Hz advertising rate and -59 measured power (which I have no idea if I should change, but that was the default value). And I have the ESP set to send every second. Maybe I should just set up 2-3 of them so one of them gets it fast?
Edit: Btw what do you have as maximum distance to report?
Max. Distance to report is 25M. Just tested with a tablet and BeaconScope app, again 1-2 seconds until it is recognized.
Disable the send every second option. Since this is bluetoothle and nearly every phone generates random ids when ping them it it useless for this case. My Espresense has the following options:
But i think your Huawei will kill the BeaconScope app as well as the home assistant companion app. Searching here in the forum i found this cool site for the energy options to be enabled or disabled:
Thanks, I’ve done that one. Still isn’t reliable. It kills Hass, but the Beacon Scope app has now been running for half an hour without stopping to broadcast, so I think that may work.
And thanks for the settings, I’ll try them and report back!
The settings seem to work just as well, if not better. But I found out that the easiest was to put ESPs more places, so that I trigger an automation that sets a phone as “coming home” when it goes from not_home to any room (there are more than one way to approach the house). Then I will put up an IR motion sensor by the door, so that if one phone has gone from not_home to a room in the last two minutes, and then the motion sensor is triggered, that will unlock the door. I think that should work. Thanks again for your help!
I’m going to reopen this topic as well, as I’ve just discovered ESPresense. I cannot get HA to recognise any sensors. (Samsung Galaxy S10+ with beacon turned on in the companion app on high.)
I’ve tried all these version (individually), both in config yaml and sensors.yaml