Closed hydazz closed 1 year ago
I don't have a bluetooth dongle to test with and there is a lot of confusing and conflicting info on the web.
For usb zwave and zigbee dongles, it's easy because they are often at /dev/ttyACMX
or /dev/ttyUSBX
, likely in a separate group like dialout
, with group rw perms so mapping those and adding the HA user to that group makes the devices accessible inside the container.
Are you sure the bluetooth device is not accessible at a separate location like those listed above besides the raw usb bus? Is it recognized by the linux kernel and the driver loaded?
Is it recognized by the linux kernel and the driver loaded
Yep, unraid does not have the drivers so they had to be installed manually. bluez is installed with nerdpack and the USB Bluetooth dongle is recognised by the host OS and can be controlled with bluetoothctl
.
from reading here it looks like the container needs to be run as privileged. I'll keep looking into this and see if I can manage to get it to work without --privileged
and without homeassistant being ran as root.
I don't have a bluetooth dongle
I assume that a raspberry pi could be used for testing to substitute a USB dongle for the built-in Bluetooth?
I've managed to get it to work: steps to get Bluetooth to work on unraid in this container (should be applicable to other OS's):
Steps 1-3 are unraid specific
bluez
with NerdPacksudo curl -L https://raw.githubusercontent.com/Realtek-OpenSource/android_hardware_realtek/rtk1395/bt/rtkbt/Firmware/BT/rtl8761b_config -o /tmp/rtl8761bu_config.bin
sudo mv /tmp/rtl8761bu_config.bin /lib/firmware/rtl_bt/rtl8761bu_config.bin
sudo curl -L https://raw.githubusercontent.com/Realtek-OpenSource/android_hardware_realtek/rtk1395/bt/rtkbt/Firmware/BT/rtl8761b_fw -o /tmp/rtl8761bu_fw.bin
sudo mv /tmp/rtl8761bu_fw.bin /lib/firmware/rtl_bt/rtl8761bu_fw.bin
/etc/rc.d/rc.bluetooth start
lsusb
, get the Bus
and Device
root@Discovery:/sys/class# lsusb
Bus 002 Device 003: ID 174c:3074 ASMedia Technology Inc. ASM1074 SuperSpeed hub
Bus 002 Device 002: ID 0781:5583 SanDisk Corp. Ultra Fit
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 1a86:7523 QinHeng Electronics CH340 serial converter
Bus 001 Device 002: ID 174c:2074 ASMedia Technology Inc. ASM1074 High-Speed hub
>Bus 001 Device 006: ID 2357:0604 TP-Link TP-Link UB500 Adapter
Bus 001 Device 004: ID 0463:ffff MGE UPS Systems UPS
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Our Bluetooth USB (Bus 001 Device 006: ID 2357:0604 TP-Link TP-Link UB500 Adapter
) is on Bus 001
, Device 006
, so our path is /dev/bus/usb/001/006
.
--device
when passing through the USB
when starting the container add --v /dev/bus/usb/<bus>/<device>:/dev/bus/usb/<bus>/<device>
and -v /run/dbus:/run/dbus:ro
apk add bluez
bluetoothctl show
, should show something like:
Controller (MAC) (public)
Name: BlueZ 5.50
Alias: BlueZ 5.50
Class: 0x00000104
Powered: yes
Discoverable: no
DiscoverableTimeout: 0x000000b4
Pairable: yes
...
Discovering: yes
Advertising Features:
ActiveInstances: 0x00 (0)
SupportedInstances: 0x04 (4)
SupportedIncludes: tx-power
SupportedIncludes: appearance
SupportedIncludes: local-name
nano /etc/services.d/homeassistant/run
, remove s6-setuidgid abc
from the run command.Mostly smooth sailing until we hit step 8, I know its highly illegal for any service to run as root but I cant see a way around it here,
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
hello, there is nothing else to do to this repo. you can easily enable bluetooth in docker by the following steps:
/etc/rc.d/rc.bluetooth start
hciconfig hci0 up
if you have many devices, try this script:
#!/bin/bash
devices=hciconfig | grep '^hci[0-9]\+' -o
for device in ${devices} do hciconfig ${device} up done
4. mount `/run/dbus` into your docker container with readonly mode.
here is the homeassistant section in my docker-compose file:
homeassistant: image: lscr.io/linuxserver/homeassistant:latest container_name: homeassistant environment:
btw, unraid 6.11 has a built-in rtl8761buv firmware, so you neednt install the firmware manually
@VergilGao I had tried that before but lacked hciconfig hci0 up
much appreciated on steps to get it working!
Following the recent release of home assistant they have broadened Bluetooth support, I would like to adopt my homekit BLE door lock into hass. I can't get it to work by myself on unraid, due to a limitation within the container
Desired Behavior
Bluetooth integration to start successfully
Current Behavior
my Bluetooth dongle is located at
/dev/bus/usb/001/004
on the host, using--device=/dev/bus/usb/001/004
to passthrough to the container Bluetooth integration won't start. bluez cant access dbus socket or the Bluetooth USB as its owned by root (i think)Alternatives Considered
home assistant wants to be run as root? how dbus and bluez work is above me