Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth adapter cannot be access #39

Open
watercrossing opened this issue Dec 4, 2024 · 0 comments
Open

Bluetooth adapter cannot be access #39

watercrossing opened this issue Dec 4, 2024 · 0 comments

Comments

@watercrossing
Copy link

watercrossing commented Dec 4, 2024

My machine has bluetooth integrated, and I want to access this from HA insider docker running in venv.
Initially my machine gets the error messages:
Failed to start Bluetooth: [org.freedesktop.DBus.Error.AccessDenied] An AppArmor policy prevents this sender from sending this message to this recipient; type="method_call", sender="(null)" (inactive) interface="org.freedesktop.DBus" member="AddMatch" error name="(unset)" requested_reply="0" destination="org.freedesktop.DBus" (bus); Try power cycling the Bluetooth hardware.

After quite a bit of digging I found an AppArmor policy https://github.com/edgexfoundry-holding/device-bluetooth-c/blob/main/docker-ble-policy that seems to work (install with sudo apparmor_parser -r -W docker-ble-policy, and adding --security-opt apparmor=docker-ble-policy to the docker call) Docker docs.

With those options set, the bluetooth integration initialises. However, 12 hours later, I get the following errors:

2024-12-04 16:12:49.415 WARNING (MainThread) [bluetooth_auto_recovery.recover] Could not reset the power state of the Bluetooth adapter hci0 [60:::::D4] due to timeout after 5 seconds
2024-12-04 16:12:49.416 WARNING (MainThread) [bluetooth_auto_recovery.recover] Could not cycle the Bluetooth adapter hci0 [60:::::D4]: [Errno 1] Operation not permitted
2024-12-04 16:12:49.417 WARNING (MainThread) [bluetooth_auto_recovery.recover] Bluetooth management socket connection lost: [Errno 22] Invalid argument
2024-12-04 16:12:54.418 WARNING (MainThread) [bluetooth_auto_recovery.recover] Could not reset the power state of the Bluetooth adapter hci0 [60:::::D4] due to timeout after 5 seconds
2024-12-04 16:12:54.421 WARNING (MainThread) [bluetooth_auto_recovery.recover] Closing Bluetooth adapter hci0 [60:::::D4] failed: [Errno 9] Bad file descriptor

Quite a few people seem to be struggling with this, see https://blog.troed.se/posts/bluetooth-and-home-assistant-in-rootless-docker/, onedr0p/containers#68, https://lucascavalare.github.io/2020-03-15-AppArmor_Docker/, home-assistant/core#76392 (this has an interesting bluetooth.conf for /usr/share/dbus-1/system.d/bluetooth.conf insider the container), and a general warning about bluetooth driver quality: home-assistant/core#92379.

Despite trying these various configurations, I can't make those bluetooth_auto_recovery.recover warnings go away. Does anyone have a suggestion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant