home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70.92k stars 29.57k forks source link

Bluetooth integration failing to initialize #121961

Closed rahulpdev closed 1 month ago

rahulpdev commented 1 month ago

The problem

After working seamlessly for nearly two years a couple of days ago my bluetooth integration has stopped working and I can see that the integration is failing to load. The only event that has occurred during this time is that my area suffered a power cut that caused full power loss to my house. My Home Assistant Yellow and HAOS are otherwise working as normal since that event and I have a Avantree DG40S USB Adapter connected to the Yellow via a USB 2.0 cable.

What version of Home Assistant Core has the issue?

core-2024.5.3

What was the last working version of Home Assistant Core?

core-2024.5.3

What type of installation are you running?

Home Assistant OS

Integration causing the issue

bluetooth

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

Logger: bluetooth_auto_recovery.recover
Source: components/bluetooth/__init__.py:320
First occurred: July 14, 2024 at 6:27:17 PM (405 occurrences)
Last logged: 6:48:24 AM

Could not cycle the Bluetooth adapter hci0 [00:00:00:00:00:00]: [Errno 110] Operation timed out

Logger: bluetooth_auto_recovery.recover
Source: runner.py:190
First occurred: July 14, 2024 at 6:27:17 PM (405 occurrences)
Last logged: 6:48:24 AM

Bluetooth management socket connection lost: [Errno 22] Invalid argument

Logger: bluetooth_auto_recovery.recover
Source: config_entries.py:575
First occurred: July 14, 2024 at 6:26:56 PM (1215 occurrences)
Last logged: 6:48:29 AM

Could not determine the power state of the Bluetooth adapter hci0 [00:00:00:00:00:00] due to timeout after 5 seconds
Could not reset the power state of the Bluetooth adapter hci0 [00:00:00:00:00:00] due to timeout after 5 seconds
Closing Bluetooth adapter hci0 [00:00:00:00:00:00] failed: [Errno 9] Bad file descriptor

Additional information

No response

home-assistant[bot] commented 1 month ago

Hey there @bdraco, mind taking a look at this issue as it has been labeled with an integration (bluetooth) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `bluetooth` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign bluetooth` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


bluetooth documentation bluetooth source (message by IssueLinks)

mib1185 commented 1 month ago

maybe the USB adapter died :thinking: try connecting the adapter to any other PC and check it it will be detected as Bluetooth device

Dwarfex commented 1 month ago

Happens to me on the yellow

mib1185 commented 1 month ago

@Dwarfex any further information? Same usb adapter? same circumstances with power outage?

Dwarfex commented 1 month ago

@mib1185 pretty identical painting -

thus no known power outage and no further devices added via the integration

2024-07-13 22:35:20.167 WARNING (MainThread) [bluetooth_auto_recovery.recover] Could not determine the power state of the Bluetooth adapter hci0 [00:00:00:00:00:00] due to timeout after 5 seconds 2024-07-13 22:35:41.185 WARNING (MainThread) [bluetooth_auto_recovery.recover] Could not cycle the Bluetooth adapter hci0 [00:00:00:00:00:00]: [Errno 110] Operation timed out 2024-07-13 22:35:41.187 WARNING (MainThread) [bluetooth_auto_recovery.recover] Bluetooth management socket connection lost: [Errno 22] Invalid argument 2024-07-13 22:35:46.187 WARNING (MainThread) [bluetooth_auto_recovery.recover] Could not reset the power state of the Bluetooth adapter hci0 [00:00:00:00:00:00] due to timeout after 5 seconds 2024-07-13 22:35:46.191 WARNING (MainThread) [bluetooth_auto_recovery.recover] Closing Bluetooth adapter hci0 [00:00:00:00:00:00] failed: [Errno 9] Bad file descriptor

with the builtin cm4 bluetooth module from the yellow

Versions: Core - 2024.7.2 Supervisor - 2024.06.2 Operating System - 12.4 Frontend - 20240710.0

Edit: did a complete reboot, problem seems to be gone for now -> will double check

bdraco commented 1 month ago

00:00:00:00:00:00 means the mac address can't be read which means is either a hardware problem, driver/kernel (operating system) problem. You'll have better luck getting help on discord in #bluetooth since this repo is for core issues so you likely won't get help with that here.

Dwarfex commented 1 month ago

@bdraco aye - thx ... so more a duplication of #92379?

bdraco commented 1 month ago

@bdraco aye - thx ... so more a duplication of #92379?

Maybe. The original kernel bug that was for that one has been fixed (at least with HAOS), but there are obviously more.

rahulpdev commented 1 month ago

@mib1185 I plugged the DG40S into my laptop and windows is picking up the bluetooth device. I also purchased a DG45 and switched it out with the original adapter on my Yellow, just to see what happens, and experienced the same outcome. I've tried deleting the bluetooth integration in HAOS and then reinstalling the integration and reconnecting the adapter but HAOS now returns the message "No unconfigured Bluetooth adapters found. There are 0 ignored adapters."

mib1185 commented 1 month ago

@rahulpdev there were some kernel bugs in HAOS, which are solved (see https://github.com/home-assistant/core/issues/121961#issuecomment-2234012155). You may need to update your HAOS first and maybe also HA Core. But as @bdraco mentioned in https://github.com/home-assistant/core/issues/121961#issuecomment-2234005045 you should look for support on our chat server or forum.

rahulpdev commented 1 month ago

@mib1185 updating HAOS seems to have done the trick thanks! It looks as though if I want to avoid such problems in the future I would be better off using Bluetooth proxy? I'm totally new to the concept of Bluetooth proxy but since I have only four BLE devices it seems a feasible solution.

mib1185 commented 1 month ago

As you got the issue solved by updating tha HAOS, I'm going to close this issue report. If you still need support in Bluetooth topics, feel free to join our chat server or forum, thx 👍