njbuch
(Niels Jakob Buch)
November 18, 2018, 6:16pm
11
Ups, and rgd where I have info about docker and bluetooth, here is a few that indicates problems related to HA - but I am not an expert, just trying to extract the conclusions. And it sure seems that you have found a way out.
I ask because in the Docker Hass, BLE is still very broken for me. I haven’t seen anything designed to fix it.
I’ve got a bluetooth speaker handy and was thinking it would be perfect for Home Assistant and TTS (and I don’t have another good use for it).
Curious if anyone has done this and has directions for using a bluetooth audio device to for Home Assistant in docker… In particular how to deal with a pairing the device. I’m already passing the bluetooth dongle into the docker container.
I was initially thinking of pairing on the host and passing /dev/snd into the container, but that doesn’t seem lik…
I am trying to get a bluetooth_tracker device working on my HA 0.65.0 setup, but HA is not detecting connected bluetooth devices. I suspect it’s because I’m running HA in a docker container, and the container isn’t accessing the USB bluetooth adapter correctly. Does anyone know what I need to do to get my docker container to use the USB bluetooth adapter?
I’m running HA on a Lubuntu guest running on an ESXi host. The Lubuntu OS recognises the USB bluetooth adapter, and I can pair my phone with …
opened 06:45AM - 10 Sep 15 UTC
closed 10:24PM - 17 Sep 23 UTC
version/1.8
Hello,
I'm trying to get my bluetooth dongle working inside a docker container.… When I try to start bluetoothd it says
```
root@a28c9bc0b5ef:~# /usr/local/libexec/bluetooth/bluetoothd -n
bluetoothd[15]: Bluetooth daemon 5.34
bluetoothd[15]: Failed to access management interface
bluetoothd[15]: Adapter handling initialization failed
```
I traced down the code inside bluez which triggers this behavior (src/shared/mgmt.c:439):
```
fd = socket(PF_BLUETOOTH, SOCK_RAW | SOCK_CLOEXEC | SOCK_NONBLOCK,
BTPROTO_HCI);
```
The socket syscall always returns -1. When I "strace" the command I see
```
socket(PF_BLUETOOTH, SOCK_RAW|SOCK_CLOEXEC|SOCK_NONBLOCK, 1) = -1 EAFNOSUPPORT (Address family not supported by protocol)
```
The same command works on the host machine without any issues. The bluetooth modules are all loaded:
```
root@a28c9bc0b5ef:~# lsmod | grep bt
btusb 28346 0
btbcm 4204 1 btusb
btintel 1332 1 btusb
bluetooth 315821 5 bnep,btbcm,btusb,btintel
```
/sys/class/bluetooth/hci0 exists both on the host as well as inside the container. It doesn't matter how I run the container. Neither --privileged nor --cap-add=ALL nor --cap-add=NET_ADMIN change this behavior. A quick glance at linux/src/bluetooth/hci_sock.c reveals that CAP_NET_ADMIN and CAP_NET_RAW should be enough to issue any command to the socket (never had anything to do with linux kernel code until yet so I don't know what exactly I'm talking about, though). I guess this is a problem with how docker(/lxc?) restricts the containers, but I don't know for sure.
Obligatory bug report information:
```
# docker version
Client:
Version: 1.8.1
API version: 1.20
Go version: go1.4.2
Git commit: b66e5ef-dirty
Built: Wed Sep 2 19:02:45 UTC 2015
OS/Arch: linux/arm
Server:
Version: 1.8.1
API version: 1.20
Go version: go1.4.2
Git commit: b66e5ef-dirty
Built: Wed Sep 2 19:02:45 UTC 2015
OS/Arch: linux/arm
# docker info
Containers: 5
Images: 27
Storage Driver: aufs
Root Dir: /var/lib/docker/aufs
Backing Filesystem: extfs
Dirs: 37
Dirperm1 Supported: true
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 4.1.6-v7+
Operating System: Debian GNU/Linux 8 (jessie)
CPUs: 4
Total Memory: 925.7 MiB
Name: raspberry
ID: T3Z3:Z6BJ:IGU5:F7HP:AGPB:LZTR:VQH2:EZUJ:HTVR:FRFX:H2RT:4V3M
WARNING: No memory limit support
WARNING: No swap limit support
# uname -a
Linux raspberry 4.1.6-v7+ #1 SMP PREEMPT Sun Aug 23 22:01:27 CEST 2015 armv7l GNU/Linux
```
Environment details: Physical (Raspberry Pi 2)
How reproducible: Always
Steps to reproduce:
1. Build container with bluez installed
2. Run with run options mentioned above (parameters don't seem to matter anyway)
3. Start bluetoothd
Actual results: Doesn't start up because it cannot open bluetooth socket
Expected results: bluetoothd starts up just fine (at least when run with the right capabilities enabled)
PS1: This also happens on amd64
PS2: This also happens when using the --device switch