Closed KennethLavrsen closed 9 months ago
Hi Kenneth, thanks for the report.
That's very surprising - I have been using it on my system for months with 6 or so proxies without anything like this happening, and I know there's at least a handful of others who have been using it for nearly as long.
Given that reading the area of the proxies and setting the area of the sensors is a core part of the functionality, it's hard to imagine how that could only pop up in an isolated case. That said, anything's possible!
Can you possibly gather some more evidence? I don't really have enough to try and reproduce the fault, so some further digging at your end might be the only way to narrow things down. If you're able to reproduce it by re-enabling the integration and gathering some debug info and a walk-through of the steps (ideally with some screenshots) that might help with being able to reproduce the issue.
My gut feeling is that it was likely to be something else going on (like HA not saving its internal state before the restart, or the earlier setting of the area not sticking for some reason), but I don't want to dismiss the possibility out of hand.
I just installed the integration again. I will need to run a few days. Thanks for being flexible. This report is below the standard I normally put on myself for bug reports.
After 4 restarts - I cannot reproduce it yet. Unfortunately after I uninstalled your integration, I also removed the 2nd ESPHome proxy and rebuilt it using the ESP-IDF framework instead of Arduino. It can be this reinstallation that has fixed it. Another theory I have gotten is that the first proxy is wired Ethernet. The second is Wifi. And the Wifi one also gets added to the Unifi integration so there are two integrations and one device. I wonder if there is a latent race thing hidden there. I will keep this open another day or two. If I cannot reproduce it I will close it. I am more confortable now that I know you inspected your code so you know you do not assign where you should compare. I really appreciate your feedback
The 2 integrations one device thing is a (welcome) feature, not a bug. Don't want to hijack this issue but it would be great if Bermuda also acted like that and added the sensors to the devices it tracked.
(not encountering the behavior described here btw)
Never claimed sharing of device between multiple integrations was a bug. Just pointing out the differences between the one that lost its area and the one that did not. Other differences was wifi vs wired, last added vs first added, and arduino based vs esp-idf. Three more restarts and the proxy in the kitchen has not lost its area.
@KennethLavrsen
And the Wifi one also gets added to the Unifi integration so there are two integrations and one device. I wonder if there is a latent race thing hidden there.
I'd expect the device in unifi would be a separate device with separate entities, and the esphome integration will have another device with its own entities, as I think devices are per-domain, and integrations each have their own domain. All these things are specific HomeAssistant terminology and I'm not completely across the finer points, but it pays to be fairly careful/specific when talking about integrations/devices/entities/domains because they all have specific, non-intuitive distinctions in HA. If I'm off-track there a screenshot or two might help explain what I'm missing.
The odds of it being a race condition in the HA or other codepaths seems pretty unlikely since it ought to have shown up a lot by now. I think what has probably happened is that while you changed a number of things in a short period of time either a setting somehow didn't get time to persist to disk or perhaps you lost track of setting the area before or after the adding/removal of something. I've done similarly plenty of times myself (and will in future)! This I think is the simplest explanation that fits the available evidence, and an alternative explanation would require a fair bit of evidence at this point. Oh.. are you setting the area in your esphome yaml or setting it in the UI in home assistant? I only use the latter, and I don't know how the esphome integration matches area names from its config with area id`s in HA - there could possibly be some little caveats you might have bumped into there, but that's unlikely to be related to Bermuda directly.
Anyway I'm glad that it seems to be working in a stable fashion for you currently - I'm going to close the ticket as there is nothing at this stage I can action.
If you find it occuring again please feel free to re-open, along with dump_devices
service output, esphome yaml, debug logs and config screenshot so we can start digging into it. ππΌ
@tbrasser
it would be great if Bermuda also acted like that and added the sensors to the devices it tracked.
I'm curious if what you are proposing might be in the latest release already or if you mean something different to what I'm thinking - v0.4.3 now creates a proper device_tracker
entity, persisted in the entity register, that is associated with the Bermuda integration. Prior to that it just created a sort of "anonymous" entity for device_tracker
so it didn't show any direct ties to Bermuda as such and was difficult to find in the UI.
Is that older behaviour what you are referring to? If so you might be pleased to try out the current version, which shows the Area, Distance and Device_Tracker sensors all together in the device: π
No I meant that I'd rather see Bermuda entities appear here for this device:
Ah OK. As far as I know it isn't possible to have the entities
of one integration
displayed on the device
page of a different integration
. That is, that Xiaomi device page can only show stuff from the Xiaomi integration, not from any other integration (because that device
belongs to the integration).
However, it's entirely possible that I'm wrong about that, as I find the HA terminology and descriptions around this stuff frustratingly confusing, so if you do find either a way to do it or an example of one integration/component that puts its entities on the device of another integration/component feel free to raise a ticket and point me to the example so I can take a look at what they're doing and how. ππΌ
I was comming here to close the ticket but you beat me to it. Thanks for the open and positive dialog.
On the other side discussion. HA allows two integrations to share a device. But they each add their own unique entities. My theory was that changing area of a device (not entity) could have a race condition. I think what fixed my problem was removing the proxy from ESP Home completely, start all over, readding it. The first time I also had a problem getting it added. I think it is an ESPHome glitch. I monitored the device storange json file when I restarted and it was during the restart that HA was overwriting the area field by an empty string. I cannot reproduce it any more so I will not create an ESPHome issue now. But I will keep a close eye next time I add a device.
@tbrasser. The example where Unifi and ESPHome and also Unifi and Tasmota share a device does not really apply to this integration. ESPHome and Tasmota devices are WiFi devices that Unifi creates a device tracker for. So they are devices with same unique MAC address.
For Bermuda, the devices are the BLE devices that are added, not the BT Proxy. Unifi see the MAC address of the Wifi Radio. Bermuda tracks the MAC addresses of the Bluetooth devices. So they should not share anything.
Yeah I will open a new issue to talk about creating the entities for Bermuda tracked devices under the existing/original integration device. (see https://developers.home-assistant.io/docs/device_registry_index/#automatic-registration-through-an-entity )
When it comes to the proxies themselves there are no entities to add.
@tbrasser thought you might like to know that in the v0.5.0 that I just released it now adds "connections" to the entities so that they should pair up other devices connected to the same MAC. Thanks for your prodding on that, I had never noticed previously that devices could span multiple integrations.
You might need to delete Bermuda and its entities then re-add it before the devices will link up though, as previous versions created their entities without the "connection" metadata that makes the linking work. I have some thermometers advertising with BTHome and the linking seems to work well here:
Thanks again for the inspiration! π
Awesome! Will test soon!
Version of the custom_component
0.4.3
Configuration
Describe the bug
I have two ESPHome Bluetooth proxies when I test. The last one added keep on loosing the area after a restart of HA and then the integration gets upset and logs errors about missing area At first I suspected it was the ESPHome integration. But then I uninstalled the Bermuda integration (because of the flooding of logs and unstable performance I raised in previous bug report today, and the problem went away. I have restarted HA at least 10 times and no loss of area for the new BT proxy.
Are you sure this integration does not accidently write to the field for area where it should read? Like a = instead of == type of bug? (I am not a Python programmer but in other languages this is a classic mistake).
I should try to install the integration again to verify the issue comes back but it is too late and I wanted to raise this before others loose their area assignments
Debug log