-
Notifications
You must be signed in to change notification settings - Fork 16
Description
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?