Bluetooth-Devices / bthome-ble

Parser for BTHome BLE devices
https://bthome.io/
MIT License
67 stars 12 forks source link

Unable to add BTHome Integration in HA #70

Closed nar1117 closed 1 year ago

nar1117 commented 1 year ago

Describe the bug I am running HA v.2023.5.3, as a VM on unRAID. I have both an ESPHome BT Proxy as well as a Bluetooth dongle adapter. Both the dongle and the ESP BT Proxy are detected by my HA automatically, and I can configure the bluetooth integration. However, the BTHome integration fails to install. The only error I get is "No devices found on the network"

To Reproduce Steps to reproduce the behavior: I can reproduce the error by trying to install the BTHome integration again. I've restarted my HA multiple times, updated everything, etc.. Same issue. Not sure how to explain how someone else would reproduce the issue besides being me with my exact setup :D

Additional context One other person seems to have a similar issue here: https://github.com/home-assistant/core/issues/88711

The diagnostic TXT file for the bluetooth integration shows that the bluetooth dongle is detecting other devices (I can see entries for various BT devices around my house), but BTHome integration does not load at all.

Please let me know if this issue should be submitted differently. I don't use github all that often so I want to make sure I'm putting this in the correct place. Thanks!

Ernst79 commented 1 year ago

Normally, if you have the Bluetooth integration running correctly, there is no need to install the BTHome integration manually. At the moment the Bluetooth integration sees a BLE message that is in the BTHome format, it will show a “new integration detected” in the integration overview. You only need to click on configure, and you’re done.

question is, does HA receive any BTHome BLE data? To find out, enable debug logging for the Bluetooth integration at debug level, and post the HA logs afterwards here and I can check. Please also post the MAC address of the sensor, if you know that.

nar1117 commented 1 year ago

Normally, if you have the Bluetooth integration running correctly, there is no need to install the BTHome integration manually. At the moment the Bluetooth integration sees a BLE message that is in the BTHome format, it will show a “new integration detected” in the integration overview. You only need to click on configure, and you’re done.

question is, does HA receive any BTHome BLE data? To find out, enable debug logging for the Bluetooth integration at debug level, and post the HA logs afterwards here and I can check. Please also post the MAC address of the sensor, if you know that.

Ok, so it looks like HA is receiving bluetooth data from the dongle, but I'm not sure if it's in a format for BTHome. I've attached the HA logs here. The MAC address of the sensor (BT dongle) is 5C:F3:70:A8:F6:57. You will see many entries for this device sensing BT data from other devices.

home-assistant_2023-05-15T06-34-23.172Z.log

Ernst79 commented 1 year ago

First, I checked your logs on servicedate from BTHome, but all service data I can find is from a sensor with UUID FEAF, which is not a BTHome sensor, but something else (Nest device).

`service_data={'0000feaf-0000-1000-8000-00805f9b34fb'

Next, I tried to search for the MAC address, but you gave the MAC address of your Bluetooth dongle (the receiver), not of the BTHome sensor.

While l was searching your logs, I notice a lot of these errors.

2023-05-14 23:36:26.900 DEBUG (MainThread) [homeassistant.components.bluetooth.base_scanner] hci0 (5C:F3:70:A8:F6:57): Scanner watchdog time_since_last_detection: 4.722009007999986
2023-05-14 23:36:56.901 DEBUG (MainThread) [homeassistant.components.bluetooth.base_scanner] hci0 (5C:F3:70:A8:F6:57): Scanner watchdog time_since_last_detection: 34.7230845009999
2023-05-14 23:37:26.904 DEBUG (MainThread) [homeassistant.components.bluetooth.base_scanner] hci0 (5C:F3:70:A8:F6:57): Scanner watchdog time_since_last_detection: 64.72619024999995
2023-05-14 23:37:56.905 DEBUG (MainThread) [homeassistant.components.bluetooth.base_scanner] hci0 (5C:F3:70:A8:F6:57): Scanner watchdog time_since_last_detection: 94.72732451999991
2023-05-14 23:37:56.906 INFO (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (5C:F3:70:A8:F6:57): Bluetooth scanner has gone quiet for 90s, restarting
2023-05-14 23:37:56.906 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (5C:F3:70:A8:F6:57): Stopping bluetooth discovery
2023-05-14 23:37:56.914 DEBUG (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (5C:F3:70:A8:F6:57): Starting bluetooth discovery attempt: (1/3)
2023-05-14 23:37:56.924 DEBUG (MainThread) [bleak_retry_connector] Restored 0 discoveries for hci0

This means there is an issue with your dongle. It detects that it isn't receiving any data for 90 seconds, it assumes that there is something wrong and it restarts the dongle. This happens every 2-3 minutes (of which 90 seconds without data).

So, to conclude, there is an issue with your Bluetooth dongle. Hard to tell what is wrong exactly. There are some issues in Home Assistant OS 10.0 and 10.1 with Bluetooth, but it can also be a faulty Bluetooth dongle.

nar1117 commented 1 year ago

This means there is an issue with your dongle. It detects that it isn't receiving any data for 90 seconds, it assumes that there is something wrong and it restarts the dongle. This happens every 2-3 minutes (of which 90 seconds without data).

So, to conclude, there is an issue with your Bluetooth dongle. Hard to tell what is wrong exactly. There are some issues in Home Assistant OS 10.0 and 10.1 with Bluetooth, but it can also be a faulty Bluetooth dongle.

Thank you for looking into this! I figured out the issue with your help.

I removed the dongle from HA, and watched the logs. The Bluetooth integration switched back to using the ESPHome BT Proxy (which was already added to my system). The logs then showed many more devices and more information. So yes, there was definitely an issue with my BT dongle.

Anyway, after getting that to work, I finally realized that I needed to send some kind of BTHome packet for the integration to pop up. The whole reason I was trying to get this to work is because I just purchased two of the Shelly Button BLU devices... so I pressed the button on one of those, and voila! The sensor showed up immediately on my integrations (wtih the BTHome logo), and I was able to configure it as normal. Very cool.

Long story short, issue has been resolved. Thanks for your help!

Ernst79 commented 1 year ago

You're welcome.