How to make Bluetooth accessible for Docker containers (ex Home Assistant) ?

  • Hi,

    I've added docker and some containers on my LibreElec setup (Rpi4). Now I would like to give Home Assistant access to built in Rpi4 Bluetooth. But I can't figure out how to do that. I think some things differs on Libreelec compared to a normal debian system to achieve that.

    I've read https://www.home-assistant.io/integrations/bluetooth/ , and according to the instructions, there should be Dbus and BlueZ installed. I can find a /run/dbus device, that I've made accessible to the docker container using a bind mount. But home assistant still is unable to scan for bluetooth devices. I'm not sure if it's because BlueZ is missing, or any other problem. Could someone read the documentation above and try to help me to achieve this ? I don't know what to try next.

    Home Assistant give me the following error when trying to scan :

    Code
    2023-03-22 21:28:27.222 ERROR (MainThread) [frontend.js.latest.202303091] :0:0 ResizeObserver loop completed with undelivered notifications.
    2023-03-22 21:28:41.254 ERROR (MainThread) [homeassistant] Error doing job: Future exception was never retrieved
    Traceback (most recent call last):
      File "/usr/lib/python3.10/site-packages/dbus_fast/aio/message_bus.py", line 214, in on_hello
        raise err
      File "src/dbus_fast/aio/message_reader.py", line 24, in dbus_fast.aio.message_reader.build_message_reader._message_reader
      File "src/dbus_fast/_private/unmarshaller.py", line 659, in dbus_fast._private.unmarshaller.Unmarshaller._unmarshall
      File "src/dbus_fast/_private/unmarshaller.py", line 533, in dbus_fast._private.unmarshaller.Unmarshaller._read_header
      File "src/dbus_fast/_private/unmarshaller.py", line 283, in dbus_fast._private.unmarshaller.Unmarshaller._read_to_pos

    Do you have an idea ? Any answer is welcome

    Have a great day

  • Ask on the Home Assistant forum.

    Hi, thanks for your answer.

    I did already, they told me to ask here. Which I find logical as the problem is more with how Libreelec handles bluetooth rather than with home assistant itself. If you can help me to find what device Libreelec uses for bluetooth, then it should be easy to mount it on docker.

    EDIT : I tried to search for both the integrated bluetooth, as well as for the bluetooth dongle that I've connected. None of them seem to be visible in /dev. I don't see any new device appearing in /dev when plugging the dongle, even with it being found that I use lsusb.

    Thanks in advance for any answer, have a good day.

  • LeVraiRoiDHyrule:

    I don't know what you're doing. LE is able to recognize very few things but recognizes my bluetooth hardware with no problem, tries to find out the hardware can be recognized on your device.

    ##############################################

    # LibreELEC #

    # https://libreelec.tv #

    ##############################################

    LibreELEC (official): 9.2.6 (Generic.x86_64)

    LibreELEC:~ # bluetoothctl list

    Controller B8:9A:xx:xx:81 LibreELEC [default]

    LibreELEC:~ #

    One other thing: I have installed and uninstalled the 'Home Assistant' docker service twice. The reason: Too complex and heavy 1.5GB, and CPU demanding even for my LE x86_64 server that needs to run the fans. I would never recommend HA for an arm device like RPi4.

    As a substitute for 'Home Assistant', I use the real-time android applications 'XMEye' for surveillance cameras, and 'Smart Life', for remote connection and disconnection of electrical devices. LE records the cameras 24 hours a day.

    Edited 3 times, last by elonesna (April 9, 2023 at 8:15 PM).

  • Hi, thanks for your answer.

    I did already, they told me to ask here. Which I find logical as the problem is more with how Libreelec handles bluetooth rather than with home assistant itself. If you can help me to find what device Libreelec uses for bluetooth, then it should be easy to mount it on docker.

    EDIT : I tried to search for both the integrated bluetooth, as well as for the bluetooth dongle that I've connected. None of them seem to be visible in /dev. I don't see any new device appearing in /dev when plugging the dongle, even with it being found that I use lsusb.

    Thanks in advance for any answer, have a good day.

    Hi,i'm using LibreELEC 11 + Docker + HA on Rpi4 8GB and when i run "hcitool dev" in HA container's terminal,it shows the RPi4's internal bluetooth ,so no idea why it fails for you.

    I will try to pair a device with it and check if Homeassistant can find it,so i will let you know .

    P.S. Docker + Home Assistant (and other 12 containers like SWAG,AdGuard Home ,Zigbee2mqtt ,MQTT ,eyc) runs very well on Rpi4 .

  • Hi,i'm using LibreELEC 11 + Docker + HA on Rpi4 8GB and when i run "hcitool dev" in HA container's terminal,it shows the RPi4's internal bluetooth ,so no idea why it fails for you.

    I will try to pair a device with it and check if Homeassistant can find it,so i will let you know .

    P.S. Docker + Home Assistant (and other 12 containers like SWAG,AdGuard Home ,Zigbee2mqtt ,MQTT ,eyc) runs very well on Rpi4 .

    Very interesting ! That's exactly what I'm trying to do. Could you tell me what device you mounted inside your container ? What paths ? How is your HA container and service configuration ?

  • I'm using docker-compose here ,but here's a snippet from the "docker-compose.yaml" file :

    With this configuration ,the RPi4's internal bluetooth is automatically detected in HA (check the attached screenshot ).

  • I'm using docker-compose here ,but here's a snippet from the "docker-compose.yaml" file :

    With this configuration ,the RPi4's internal bluetooth is automatically detected in HA (check the attached screenshot ).

    Thanks a lot for your answer. That's strange, when I use "bluetoothctl list" I correctly have LibreELEC bluetooth listed from within HA container, but when I use "hcitool dev", I don't have any device appearing. I don't know what I'm missing.

  • LeVraiRoiDHyrule which LibreELEC version you are using (i'm using LE11 here)?

    Also which HA container image ?

    Alternatively ,you could use esphome bluetooth proxy ,installed on esp32 dev module (already tested here and working ).

    Hi, sorry for the late reply. I'm using LE11 too. My container image is from LinuxServer.io. I discovered that if I run the container as my root user, I can correctly add the Bluetooth adapter in HA. But not device is being discovered, even if they are found using bluetoothctl scan on, HA doesn't seem to see any. Hcitool dev still finds no device. I don't know what to do. Here is my Docker compose config :

    I am running in bridge mode and not host mode, I was told this doesn't interfere with Bluetooth.

  • As a test can you pair bluetooth in libreelec as in this video?

    External Content www.youtube.com
    Content embedded from external sources will not be displayed without your consent.
    Through the activation of external content, you agree that personal data may be transferred to third party platforms. We have provided more information on this in our privacy policy.

  • I am running Libreelec 11 on an Rpi4 and was having the same problem as the OP.

    I changed the docker image from 'http://lscr.io/linuxserver/homeassistant' to the official 'homeassistant/home-assistant' and the bluetooth was immediately recognized and Home Assistant began discovering devices. You still need to add the volume '/run/dbus:/run/dbus:ro' to you docker command or docker-compose. The issue seemed to be with the image.

    Just figured I would contribute my solution to this issue since the OP stopped replying.