Bluetooth not working on NUC in HA Docker

Hi, I recently upgraded my HA setup to NUC via Docker on Ubuntu 18 system. Everything seems to work the way I want it to except Bluetooth device tracker.
I have looked at quite a few threads here and none seem to be able to solve my problem. Not sure what is going on with the NUC.

Here are some of the things which I have tried already.

  • NUC Bluetooth is working absolutely fine, trying the bluetoothctl shows all of my connected devices.
  • HA network is set to host.
  • Tried restarting HA container a few times but the device tracker never comes on.

Following is the error I see in the logs

Error setting up platform bluetooth_tracker
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/components/device_tracker/__init__.py", line 183, in async_setup_platform
    disc_info)
  File "/usr/local/lib/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/app/homeassistant/components/device_tracker/bluetooth_tracker.py", line 42, in setup_scanner
    import bluetooth
ModuleNotFoundError: No module named 'bluetooth'

Can anyone help me figure out what is wrong with the setup?

Make sure your image is privledged. This gives it access to everything. Also, on the host system, try installing these:

sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev libusb-1.0-0-dev

Any luck sorting this out? Same issue here, sadly.

What fo you mean by privileged? I am pulling jh hair bluetooth has stopped working after 0.94.3 for me on docker

Privledged gives the container more access to the system. This should expose all the hardware on your machine. You can use the --privileged option or add privileged: true to your docker-compose.yaml file.

Some information here that explains it better (LINK).

Here is my docker compose entry for Home Assistant if it helps.

  homeassistant:
    container_name: homeassistant
    image: homeassistant/home-assistant:latest
    restart: unless-stopped
    network_mode: host
    privileged: true
    depends_on:
      - mosquitto
      - nodered
    volumes:
      - /srv/docker/homeassistant/config:/config
      - /srv/docker/homeassistant/db:/db
      - /etc/localtime:/etc/localtime:ro
1 Like

If you’re using network mode= host that should be all that’s needed since Bluetooth is part of the network stack

I already had privileged as true but bluetooth is still not working for me

Try installing the bluetooth libraries on the Docker host.

sudo apt install python-bluez bluetooth libbluetooth-dev

I get this error:

root@nuc:/usr/src/app# apt-get install python-bluez bluetooth libbluetooth-dev
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package python-bluez

apt search bluez

find the appropriate package that looks similar.

looks like I have already got them installed:

root@nuc:/usr/src/app# apt search bluez
Sorting... Done
Full Text Search... Done
bluetooth/now 5.43-2+deb9u1 all [installed,local]
  Bluetooth support

bluez/now 5.43-2+deb9u1 amd64 [installed,local]
  Bluetooth tools and daemons

libbluetooth-dev/now 5.43-2+deb9u1 amd64 [installed,local]
  Development files for using the BlueZ Linux Bluetooth library

libbluetooth3/now 5.43-2+deb9u1 amd64 [installed,local]
  Library to use the BlueZ Linux Bluetooth stack

well, I can say that my bluetooth is working fine inside Docker HA.

have you used any of the bluetoothctl options yet? to make sure your bluetooth is working on the host?

bluetooth is working fine on the host…here it is:

root@nuc:/usr/src/app# exit
exit
bachoo786@nuc:/srv/docker/homeassistant$ bluetoothctl
Agent registered
[CHG] Device 58:2D:34:32:E1:6F Connected: yes
[CHG] Device 58:2D:34:32:E1:6F Connected: no
[bluetooth]#

bluetooth inside Docker HA used to work all fine until the 0.94 update. I tried downgrading to 0.93 but it still didnt work.

I cannot work it out if its my NUC which I updated recently (sudo apt-get update && sudo apt-get upgrade) that has caused problems. Bluetoothctl works fine

Did you ever make this work?

1 Like

Any news on this one?
I have the exact same problem :frowning: