Bluetooth in Docker?

I would really love it if the producers of the Docker images (thanks!) would install the prerequisites for Bluetooth LE so that could be used for tracking. I RTFM’d and tried Docker exec installing the suggested things and a million and one other googled suggestions but just couldn’t get it to work. I’m running my container on a Nuc which has built in Bluetooth and I’ve also bought and tried a dongle to no avail. Any progress here would be extremely appreciated!

1 Like

Bluetooth works for me.

What did you do to get Bluetooth working? Any pre-reqs on the host system or special pass through settings for the container?

bluetooth is just another network device. if you are using --net = host you are effectively passing it through.

2 Likes

I’m using the host network, but when I try to use the Bluetooth device tracker, I get this error on startup. What am I missing?

Am using a NUC6CAYS (Celeron). It does have Bluetooth.

2018-03-16 11:40:39 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform bluetooth_tracker
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/components/device_tracker/__init__.py", line 188, in async_setup_platform
    disc_info)
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 327, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 243, in result
    raise self._exception
  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 65, in setup_scanner
    for dev in discover_devices():
  File "/usr/src/app/homeassistant/components/device_tracker/bluetooth_tracker.py", line 43, in discover_devices
    lookup_class=False)
  File "/config/deps/lib/python3.6/site-packages/bluetooth/bluez.py", line 26, in discover_devices
    device_id = _bt.hci_get_route()
OSError: [Errno 19] No such device

Ubuntu server?

https://docs.ubuntu.com/core/en/stacks/bluetooth/bluez/docs/reference/pairing/introduction

I’m still not sure what I’m supposed to do. I installed Bluez on the main system just to see what happens and now my error in Hass changed.

2018-03-16 12:28:24 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform bluetooth_tracker
Traceback (most recent call last):
  File "/usr/src/app/homeassistant/components/device_tracker/__init__.py", line 188, in async_setup_platform
    disc_info)
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 327, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/local/lib/python3.6/asyncio/tasks.py", line 250, in _wakeup
    future.result()
  File "/usr/local/lib/python3.6/asyncio/futures.py", line 243, in result
    raise self._exception
  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 32, in setup_scanner
    import bluetooth
ModuleNotFoundError: No module named 'bluetooth'

you need to verify bluetooth is working on host OS first. try using bluetoothctl to test

Not sure what I did but it didn’t work during one Hass restart, then worked the next.

I haven’t been as lucky as @gregg098. I know that bluetooth is working on the NUC because I’m able to connect my keyboard and mouse, but HA isn’t creating a new known devices file on HA.

Any other ideas? Is there something else that HA needs to be installed for this to work?

Have you tried using bluetoothctl to see if it can see your devices?

I still don’t know how I got mine working, but I have to say the range on the NUC is great. I can now pull into my driveway and be “home” within seconds. I used to have to get near the front door for the RPi to see it.

is it Bluetooth or BLE? I’m trying to get BLE beacons working.

It probably does both. I only use the normal BT tracker.

I ask because in the Docker Hass, BLE is still very broken for me. I haven’t seen anything designed to fix it.

I have installed Hassio with Portainer on my NUC with Ubuntu 18.04 using these commands after a clean install:

#Apt update
#Apt upgrade
#apt-get install -y apparmor-utils apt-transport-https avahi-daemon ca-certificates curl dbus jq network-manager socat software-properties-common
#curl -sSL https://get.docker.com | sh
#sudo docker run --restart=always -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer
#curl -sL "https://raw.githubusercontent.com/home-assistant/hassio-installer/master/hassio_install.sh" | bash -s

Everything seems to work just fine but I am not able to connect my bluetooth dongle through docker. I cannot change the network settings or anything else and I am stuck using my mi-flora sensors!

Tried installing via https://www.home-assistant.io/docs/installation/docker/ but after installation I cannot access the Hass.io tab within the fresh install.

Does anyone know how to connect my bluetooth dongle via Hassio or do I have to reinstall using the docs for docker installation?

Hope someone can help me with this issue.

Same here. Use Hass on a NUC with docker. Added dbus to my volumes section in my docker-compose.yaml stack and verifyed on the host if it could see my bluetooth adapter using bluetoothctl (and yes it’s there!)

docker-compose.yaml:

  volumes:
   - /run/dbus:/run/dbus:ro
   - /etc/localtime:/etc/localtime:ro
   - /opt/ha:/config

bluetoothctl:

me@nuc:~$ bluetoothctl
Agent registered
[CHG] Controller 00:15:83:45:69:5E Powered: yes
[CHG] Controller 00:15:83:45:69:5E Class: 0x00000104
[CHG] Controller 00:15:83:45:69:5E UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Controller 00:15:83:45:69:5E UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Controller 00:15:83:45:69:5E UUIDs: 0000110e-0000-1000-8000-00805f9b34fb
[CHG] Controller 00:15:83:45:69:5E Alias: BlueZ 5.64
[CHG] Controller 00:15:83:45:69:5E Pairable: yes
[CHG] Controller 00:15:83:45:69:5E Name: nuc
[CHG] Controller 00:15:83:45:69:5E Alias: BlueZ 5.64
[CHG] Controller 00:15:83:45:69:5E Alias: nuc
[bluetooth]# 

However, even after restart, HA will report ‘no bluetooth adapter’ when I try to add the bluetooth integration…