Bluetooth seems to work fine but Xiaomi BLE devices does show up

Hi all!

I’m trying to setup a new instance of home assistant on my Raspberry Pi 4. I would like to integrate a Xiaomi H&T BLE ( LYWSD03MMC ) using the built-in bluetooth adapter.

I installed Home Assistant using Docker, this is the docker-compose.yml:

version: '3'
    container_name: home-assistant
    image: homeassistant/home-assistant:2022.11.1
      - ./${PROJECT_DATAS_FOLDER}/home-assistant/config:/config
      - /etc/localtime:/etc/localtime:ro
      - /run/dbus:/run/dbus:ro
    restart: unless-stopped
    privileged: true
        ipv4_address: ${NETWORK1_SUBNET}.78
     - /dev/serial1:/dev/serial1
      - "traefik.enable=true"
      # .. other traefik labels

As shown by the docker-compose I am using Home Assistant version 2022.11.1 and I’d prefer not using the network mode host.

As shown by the following screenshot, I am able to see the adapter in the integration page. However I cannot see the Xiaomi BLE device I want to integrate.

The Xiaomi BLE device is up and running, I can see it even from Windows and from my phone.

Additional information:

My host system has installed bluez-5.65-3.

Linux kernel:

$ uname -a
Linux raspberry 5.15.74-2-MANJARO-ARM-RPI #1 SMP PREEMPT Thu Oct 20 16:43:17 UTC 2022 aarch64 GNU/Linux

I also tried to scan bluetooth devices using bluetoothctl from the host and from the docker, here the results:

# scan from the host
[pi@raspberry services]$ bluetoothctl scan on
Discovery started
[CHG] Controller E4:5F:01:**:**:** Discovering: yes
[NEW] Device A4:C1:38:**:**:** LYWSD03MMC

# open a shell inside the docker
[pi@raspberry services]$ docker exec -it home-assistant /bin/bash
# scan from the docker
bash-5.1# bluetoothctl scan on
Discovery started
[CHG] Controller E4:5F:01:**:**:** Discovering: yes
[CHG] Device A4:C1:38:**:**:** RSSI: -54

In “settings → system → logs” I found this ERROR message:

Logger: homeassistant
Source: components/bluetooth/
First occurred: 12:51:57 (164 occurrences)
Last logged: 14:15:04

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/", line 372, in _async_scanner_watchdog
    await self._async_reset_adapter()
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/", line 389, in _async_reset_adapter
    result = await async_reset_adapter(self.adapter)
  File "/usr/src/homeassistant/homeassistant/components/bluetooth/", line 112, in async_reset_adapter
    return await recover_adapter(adapter_id)
  File "/usr/local/lib/python3.10/site-packages/bluetooth_auto_recovery/", line 251, in recover_adapter
    async with MGMTBluetoothCtl(hci, MGMT_PROTOCOL_TIMEOUT) as adapter:
  File "/usr/local/lib/python3.10/site-packages/bluetooth_auto_recovery/", line 116, in __aenter__
    await self._setup()
  File "/usr/local/lib/python3.10/site-packages/bluetooth_auto_recovery/", line 137, in _setup
    self.sock =
  File "/usr/local/lib/python3.10/site-packages/btsocket/", line 58, in open
    raise BluetoothSocketError("Unable to open PF_BLUETOOTH socket")
btsocket.btmgmt_socket.BluetoothSocketError: Unable to open PF_BLUETOOTH socket

What am I doing wrong?

Apparently I was missing to add a device in the devices list in the docker-compose.yml:

$ ls -la /dev/serial1 
lrwxrwxrwx 1 root root 7 Oct 21 02:57 /dev/serial1 -> ttyAMA0

Adjusting this fixed the issue:

     - /dev/serial1:/dev/serial1
     - /dev/ttyAMA0:/dev/ttyAMA0

Now I am able to see the Xiaomi BLE in the device list, it seems to be not working properly but that’s a different kettle of fish.