Asus BT400 in HA container 500 Internal Server Error Server got itself in trouble

This is my setup to get bluetooth BCM20702A1 working on my unraid box that runs HA in a container.

Hello! I have managed to make this usb dongle work on unraid but I cant seem to make it show up in the container.

Dongle is Asus bt400

This is my current setup:

  1. downlaoded bluetooth dongle fw from this repo GitHub - winterheart/broadcom-bt-firmware: Repository for various Broadcom Bluetooth firmware
  2. copied it over to the boot/firmware/brmc folder (had to create) cp /mnt/user/backup/BCM20702A1-0b05-17cb.hcd /lib/firmware/brcm/
  3. Replugged usb
  4. downloaded bluez wget -P /boot/extra https://slackware.uk/slackware/slackware64-15.0/slackware64/n/bluez-5.63-x86_64-2.txz
  5. installed bluez using installpkg /boot/extra/bluez-5.63-x86_64-2.txz
  6. Made the device show up in unraid as hci0 using hciconfig, hciconfig hci0 up,
  7. I can scan devices etc with hcitool lescan
  8. I passed the PATH of the device to the HA container running in privileged mode, running. (ID from lsusb) /dev/bus/usb/001/007 -> /dev/bus/usb/001/007
  9. I try installing bluetooth or running hcitool inside HA container, get nothing.
  10. I passed a /run/dbus as read-only path. When I try to install the HA bluetooth integration I get the following error:
Config flow could not be loaded: 500 Internal Server Error Server got itself in trouble
2023-06-21 05:43:54.150 ERROR (MainThread) [homeassistant] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/entity_platform.py", line 471, in async_add_entities
    await asyncio.gather(*tasks)
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/entity_platform.py", line 711, in _async_add_entity
    raise HomeAssistantError(f"Invalid entity ID: {entity.entity_id}")
homeassistant.exceptions.HomeAssistantError: Invalid entity ID: switch.unraid_vm_windows_11_usb_nbsp_nbsp_nbsp_nbsp_nbsp_nbsp_nbsp_input_type_checkbox_name_usbopt_1b1c_1c0c_id_usbopt2_value_1b1c_1c0c_nbsp_nbsp_nbsp_nbsp_nbsp_input_type_number_size_5_maxlength_5_id_usbboot2_class_narrow_bootorder_style_width_50px_name_
2023-06-21 05:44:01.340 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/lsiopy/lib/python3.11/site-packages/aiohttp/web_protocol.py", line 433, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/aiohttp/web_app.py", line 504, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/aiohttp/web_middlewares.py", line 117, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/security_filter.py", line 85, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/forwarded.py", line 227, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/request_context.py", line 28, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/ban.py", line 80, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/view.py", line 148, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/config/config_entries.py", line 149, in post
    return await super().post(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/http/data_validator.py", line 72, in wrapper
    result = await method(view, request, data, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/helpers/data_entry_flow.py", line 71, in post
    result = await self._flow_mgr.async_init(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/config_entries.py", line 845, in async_init
    flow, result = await task
                   ^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/config_entries.py", line 873, in _async_init
    result = await self._async_handle_step(flow, flow.init_step, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/data_entry_flow.py", line 367, in _async_handle_step
    result: FlowResult = await getattr(flow, method)(user_input)
                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/bluetooth/config_flow.py", line 143, in async_step_user
    return await self.async_step_multiple_adapters()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/homeassistant/components/bluetooth/config_flow.py", line 103, in async_step_multiple_adapters
    await bluetooth_adapters.refresh()
  File "/lsiopy/lib/python3.11/site-packages/bluetooth_adapters/systems/linux.py", line 33, in refresh
    await self._bluez.load()
  File "/lsiopy/lib/python3.11/site-packages/bluetooth_adapters/dbus.py", line 30, in load
    self._packed_managed_objects = await _get_dbus_managed_objects()
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/bluetooth_adapters/dbus.py", line 94, in _get_dbus_managed_objects
    bus = await MessageBus(bus_type=BusType.SYSTEM).connect()
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/dbus_fast/aio/message_bus.py", line 235, in connect
    return await future
           ^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/dbus_fast/aio/message_bus.py", line 214, in on_hello
    raise err
  File "/lsiopy/lib/python3.11/site-packages/dbus_fast/aio/message_reader.py", line 24, in _message_reader
    message = unmarshaller._unmarshall()
              ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/lsiopy/lib/python3.11/site-packages/dbus_fast/_private/unmarshaller.py", line 662, in _unmarshall
    self._read_header()
  File "/lsiopy/lib/python3.11/site-packages/dbus_fast/_private/unmarshaller.py", line 536, in _read_header
    self._read_to_pos(HEADER_SIGNATURE_SIZE)
  File "/lsiopy/lib/python3.11/site-packages/dbus_fast/_private/unmarshaller.py", line 282, in _read_to_pos
    data = self._stream_reader(missing_bytes)  # type: ignore[misc]
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/socket.py", line 706, in readinto
    return self._sock.recv_into(b)
           ^^^^^^^^^^^^^^^^^^^^^^^
ConnectionResetError: [Errno 104] Connection reset by peer

If you gain command line in container can you see hci0?

No, devices are empty , I should probably address that first

root@37e84f40b322:/# hciconfig
Can't open HCI socket.: Address family not supported by protocol
root@37e84f40b322:/# hcitool dev
Devices:

Did you end up solving that “Can’t open HCI socket”?

no, not yet, might switch to VM just to avoid all this trouble

I ended up purchasing an Atom m5stack to install ESPhome, quite easier to be honest.

1 Like

How does that solve the problem? Is it a bluetooth device that connects to HA over the network?

It works as a bluetooth proxy that will then recognise the rest of your bluetooth devices. Also, given that works over wifi as well you don’t need to have a “physical” connection like the bluetooth dongle.

1 Like

Thanks, did this as I had a esp32 laying around. works nicely

1 Like

Great to hear that it worked.