bermuda icon indicating copy to clipboard operation
bermuda copied to clipboard

BLE private device didn't add itself to Bermuda

Open erkr opened this issue 10 months ago • 10 comments

First, I'd like to thank you for your tremendous work. I like it.

Describe the bug

I added a private BLE device in HA. That device didn't auto magically add to Bermuda!

So I looked up the current MAC address as added that device via the integration config. Now Bermuda added the device twice!

Both "The private BLE" and "a MAC based device" where added. The latter one was not needed: image

I tried to get rid of the MAC based device as it is double and the MAC changed in the mean time.

I'd I disable the device, BUT it reappears enabled after a reload of Bermuda

Update: After a few attempts I managed to really delete the device (not disable, and not re apearing after a restart).

So my question: according the documentation, Private BLE devices should be added auto magically. In my case that didn't happen. Any advice how to get that done with the next device?

Diagnostics

config_entry-bermuda-01JMSJQW0G1RTSR6S6EJRRCBXR.json

erkr avatar Feb 23 '25 23:02 erkr

Hi Eric!

I added a private BLE device in HA. That device didn't auto magically add to Bermuda!

That's a bit odd, as long as the private ble integration sees the device, it should show up straight away, or at least after a reload.

So I looked up the current MAC address as added that device via the integration config. Now Bermuda added the device twice!

Hmm... more correctly, it then added both devices, the one you manually added and the private ble device, as they are separate "devices" in this context.

I tried to get rid of the MAC based device as it is double and the MAC changed in the mean time. I'd I disable the device, BUT it reappears enabled after a reload of Bermuda

I was unable to replicate this behaviour. A disabled device does not re-enable on reloading Bermuda as far as I can see. If you can give exact steps for reproducing this that might help me find the issue.

Update: After a few attempts I managed to really delete the device (not disable, and not re apearing after a restart).

Currently, if you delete the device in HA, it will be recreated on Bermuda restart if the device is still in Bermuda's "Select Devices" list, which is not ideal. I do plan to resolve that.

So my question: according the documentation, Private BLE devices should be added auto magically. In my case that didn't happen. Any advice how to get that done with the next device?

Any time that I have tested this recently, it just works. I haven't been able to reproduce this on my systems. If you are able to replicate the issue it would be great if you could give detailed steps and also a diagnostics from Bermuda after adding the device to Private BLE. Debug logs from Bermuda might also be helpful. Also if you can include a screenshot from Private BLE Device to show the device details and the attributes of the device tracker - it should look a bit like this:

Image

agittins avatar Mar 03 '25 08:03 agittins

Hi @agittins

Today I added a new private BLE device "BLE A12". Pity the issue reproduced only partly:

  • Initially it didn't add automagically (diagnostics before reload)
  • after a reload of Bermuda it was added this time (diagnostics after reload)

config_entry-bermuda-before reload.json

config_entry-bermuda-after-reload.json

update: There was a warning and related errors in my log when the private BLE was added. I must have overlooked then the previous time:

bermuda.log

erkr avatar Mar 03 '25 17:03 erkr

update: There was a warning and related errors in my log when the private BLE was added. I must have overlooked then the previous time:

Aha, well spotted! This is probably the smoking gun that should help me replicate the issue, thanks! It looks like there might be a race condition or something.

I'll need to check if this is addressed in some unreleased changes already, it rings a bell but I'm not sure. Either way this should help track it down and fix it.

(note to self when I'm looking into it later: new irk device gets a key error in entity setup on coordinator.devices[address]. Happens even if previous irk devices exist, so maybe we're calling the new device signal before the coordinator's device entry is populated (or outside chance entity is looking at a stale coordinator object)).

agittins avatar Mar 04 '25 09:03 agittins

Resolving Unreproducible issues without diagnostics is very hard. So "It rings a bell" sound promising 😊

erkr avatar Mar 04 '25 10:03 erkr

Maybe relevant: I saw the warning mentioned before pop up spontaneously today. Just out of the blue:


This error originated from a custom integration.

Logger: custom_components.bermuda
Source: custom_components/bermuda/coordinator.py:923
integration: Bermuda BLE Trilateration (documentation, issues)
First occurred: 14:15:12 (1 occurrences)
Last logged: 14:15:12

Metadevice already tracked despite not existing yet. 38363938353630333034393236393300_1_1

erkr avatar Mar 07 '25 18:03 erkr

Hey Eric, with 0.8.2 out the door today I think that this issue should probably be solved. I ended up rewriting a lot of the setup and scanning routines in Bermuda so things are cleaner and working better in general. Also the sensors for distance to each scanner are created as proxies are discovered / removed, rather than during device setup, so those should work better as well, and metadevices (iBeacons and IRK-tracked private BLE devices) have a cleaner implementation, too.

agittins avatar May 20 '25 21:05 agittins

Good news, I will give it some testing later this week😎

erkr avatar May 20 '25 22:05 erkr

i have 0.8.2 and it is still a problem i think private ble dont appear in bermuda unless i restart Home Assistant. then its in the list

DunklerPhoenix avatar May 22 '25 17:05 DunklerPhoenix

@DunklerPhoenix I just released v0.8.4, which does have some changes in the initialisation which might affect this.

If you can give it a try, and if it doesn't work could you do a "Download Diagnostics" in Bermuda, and upload the result here? You'll need to do it after adding the private ble device but before it appears in Bermuda, so I can see what the internal state looks like.

It would also be awesome if you are able to have Bermuda in "Debug Logging" mode during that time, and send me the log after it's done. Note that the logs will contain the IRKs and MAC addresses, so don't upload them here - you can email them to me [email protected] - but if that's too much just the diagnostics should be a lot of help in seeing what's going on.

agittins avatar May 23 '25 05:05 agittins

Done - see [email protected]

DunklerPhoenix avatar May 23 '25 08:05 DunklerPhoenix