-
-
Notifications
You must be signed in to change notification settings - Fork 19
Troubleshooting
Bermuda is quite simple conceptually ("Use signal strength and math to localise bluetooth devices") but for various reasons becomes a fairly complex beast by the time things are implemented. Some things that cause this are:
- Homeassistant has very particular ways that it thinks about and does things, plus supports a legacy of previous ways it thought about and did things
- The developer has half a life time (at most, hopefully) of different ways, and is new to HA and relatively new to python.
- Each layer in the stack (physical bluetooth devices, esphome, linux, blueZ, python, HA, Bermuda) overloads the terminology of just about everything, making it really hard to accurately talk about things without adding clarification. For example, you have a physical bluetooth "device". The Bluetooth spec might call that a "coordinator" or "peripheral" instead. But HA also has things called co-ordinators, and things called devices, and it's neither of those. Internally, Bermuda calls things "device"s, but what it means by that is "a mac address, or an iBeacon UUID+major+minor, or an IRK (Private bluetooth device) key" etc. So it can get really confusing when talking about "devices" or "sensors" when troubleshooting.
So, it can be quite helpful to take a methodical approach to troubleshooting issues so that you have clarity about what aspects or layers you are looking at, and where issues might be hiding.
Bermuda tries to find as much info for you as it can. The first page of the CONFIGURATION
flow will give you some quick diagnostics. Go to "Settings", "Devices and Services", "Bermuda" then "CONFIGURE". You should see something like this:
Actually, hopefully you'll not see any skull-and-crossbones! This page tells you how many bluetooth devices Bermuda can see, and how many "proxies" or "scanners" you have set up in HA. It will also let you know when the last advertisement was received from each scanner, so you can tell if some or all of them are actively reporting data. In the example above we can see that 12 out of 24 devices appear active (this is good - as long as "some" appear active, that's good, and the inactive ones are possibly old addresses no longer being used, or devices that have appeared but since gone out of range, etc. The number of active and present scanner devices should be equal - there's no good reason for a scanner to not be active. The table shows that the Prox-test scanner in this case has not reported any bluetooth advertisements for 41 seconds! This number should be between 0 and 3 seconds. If all scanners have that (and will therefore have check-marks) then your proxy->HA->Bermuda setup looks OK.
The next few steps can be a bit intimidating, so feel free to skip to Device and Scanner counts below - if things look OK there you can be pretty sure your general setup is probably OK, and you'll only need to dig around in the esphome/ha layers if you have specific issues with particular devices.
Mobile phone apps like NRFConnect can be super helpful, because they directly show you what a physical bluetooth device is sending out through the air, well before any of the complexities of a HA bluetooth stack come into play. It is available for both Android and iOS. This is usually about as close to the physical device you can get, short of doing some electronics.
If you can not find your physical device in an app like NRFConnect, then there is no way that HA or Bermuda is going to find it, either.
You can use logging on the esphome device to see what it is seeing, but this is probably not really necessary in most cases, because the link between ESPHome and HA is pretty solid, in that if anything is getting through, you can be pretty sure that everything is getting through. Also, enabling logging on the esphome might actually alter the nature of the problem, since the device is already quite busy just doing bluetooth stuff, and adding logging as well can further stretch the system resources. Just make sure you have the recommended ESPHome settings and you'll typically be OK.
-
You can "Enable Debug Logging" on the
ESPHome
integration. This will cause the HA logs to include information about all of the bluetooth advertisements received from esphome bluetooth proxies. When you turn debug logging off, your browser will prompt you to save the generated logs. You could also watch the logs in realtime if you are able to ssh into your HA server (I usedocker logs --tail=80 -f homeassistant
which works if you are using HAOS or a typical docker setup). -
If you have a local bluetooth adaptor installed, you should see the "Bluetooth" integration in "Settings", "Devices and Services". This integration has a "Download Diagnostics" option which includes a full dump of the received BLE advertisements, which is exactly the source that Bermuda uses for all of its work.
In versions v0.6.8 and after (and main
from July 12, 2024) Bermuda's configuration dialog will display how many scanners it can see, how many bluetooth devices it can see, and how many of those are "active", meaning they have timestamps less than 10 seconds
old. This can be helpful to know if your bluetooth backend is working properly.
- Go to "Settings", "Devices and Services", "Bermuda"
- Click
CONFIGURE
- Note the text at the top of the dialog
- You can just close the dialog at that point, you don't need to go through the "Submit" steps.
Screenshot:
If the device or scanner counts look off, Bermuda will give some hints as to what you can do about it. Generally, it will boil down to checking your HA bluetooth config, ESPHome Config and Shelly bluetooth proxy settings.
The diagnostics function (added to main
July 12, 2024, present in versions >= v0.6.8) gives you a json file containing specifics about how your Bermuda installation is configured and also the current internal state of the integration (list of devices, their properties etc). The information is "redacted", meaning that all the MAC addresses are replaced with non-identifying names to guard your privacy. This is intended to make the file safe to post publicly online, but you are still advised to look through the file in case you have device names or other features that disclose information you would rather protect.
Rather than simply replacing the MAC addresses with xxxx
or similar, Bermuda assigns each address an identifier (like CONF_DEV_3) with which it replaces each occurrence of that MAC. Bermuda also retains the first and last octet of the original MAC, so that it is not enough to uniquely identify it globally, but should give enough of a clue that you can match that identifier with a known device in your config.
- Go to "Settings", "Devices and Services", "Bermuda"
- Click the "meatballs" menu (3 dots arranged vertically) next to the
CONFIGURE
button - Choose "Download Diagnostics"
Screenshot:
Most of the information in the "Download Diagnostics" file is gathered from Bermuda's
dump_devices
service. You can access this data directly on your system by browsing to "Developer Tools", "Services" and choosingbermuda.dump_devices
from the services list. This allows you to view the data directly without redactions.
-
You can simply rename your entities if you like.
-
You can also tell your bluetooth proxies to send an inquiry in response to advertisements, this might cause names to show up. Consider also though that it means while your proxy is asking a device for its name it can't be listening for BLE traffic to proxy. In esphome, this is done by adding
active: true
to theesp32_ble_tracker
section (this is separate from the active property of thebluetooth_proxy
section, which controls outbound client connections).The default is
True
, and the templates at Ready-Made Projects also default toTrue
.To be explicit in setting the option, the YAML should contain a section like this (there migth be extra paramaters, that's OK):
esp32_ble_tracker: scan_parameters: active: True
-
Also, when you first restart homeassistant after loading the integration it may take a minute or so for the system to collect the names of the devices it sees.
- If your device is a "wearable" or otherwise attached to a mammal, the signal strength will tend to vary a lot,
and receivers in different directions will get differing signals due to the body absorbing signals travelling
through it (some signal will usually still arrive, but possibly via reflections instead of directly).
This makes it difficult/impossible to tell which receiver is physically closer to the device on signal strength
alone. There are a few workarounds you can try:
- More distance between proxies. If you have two adjacent rooms, avoid putting the proxies on either side of the common wall. Instead, move one or both so that they have more separation, giving them a better chance to distinguish the signal strength.
- Add a second (or third!) proxy in the same area. When one proxy is blocked by a body, the other one might get a stronger signal. Obviously this is not ideal financially, but it can make a significant difference.
- Wait for trilateration (but still keep deploying proxies in the meantime!). Trilateration will use the signals from all proxies to decide which Area a device is in. Hopefully this will mean much higher accuracy, since Bermuda can then make better choices about device locations under more challenging signal conditions.
Measuring distance using RSSI is inherently noisy, so it's important to have reasonable expectations. However we typically find that Bermuda can do a reasonable job in most cases, and the simplistic area matching we have currently (prior to having trilateration support) should be fairly stable.
That said, it's possible that your proxy is rebooting, crashing or dropping off the network:
- If you are using esphome proxies,
you might have your
window
andinterval
timings set too close to each other, or they might be too long or too short. - If you are using Shelly devices, it's possible that you have a non-standard BLE script installed, or perhaps multiple BLE scripts installed on the device. Use the latest firmware, and only install the BLE script that comes bundled with the HA Shelly integration - it will automatically install it for you when you configure either Passive or Active Bluetooth Scanning.