Home Assistant Bluetooth integration

I have recently purchased an Xiaomi LYWSD03MMC BLE temperature and humidity sensor, I would like to connect this device to my Home Assistant system.

Therefore, I would like to enable Bluetooth integration to Home Assistant. When I attempt to add the integration it says:

No unconfigured Bluetooth adapters found

There is a help link that points to Bluetooth - Home Assistant and I believe Balena would fall under this.

  • Home Assistant Container: The host system must run BlueZ, and the D-Bus socket must be accessible to Home Assistant inside the container.

I believe D-Bus access is achieved by adding the io.balena.features.dbus: '1' label to homeassistant service in docker-compose.yml.

But, I don’t know how to run bluez on the host system. I have connected to the Balena HostOS serial console and noticed there are HCI tools already installed, from there I was able to run hcitool lescan and the device I want to connect to is discovered:

root@2b97a16:~# hcitool lescan
LE Scan ...
...
A4:C1:38:F3:FA:1B ATC_F3FA1B

This tells me bluetooth already is available to the host … So why am I unable to detect the BLE device in Home Assistant :-/

I added the PVVX firmware to the sensor and have been able to add as a BTHome integration.

I do notice this error and warnings though:

 homeassistant  2023-01-01 23:53:05.692 ERROR (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (B8:27:EB:0E:64:EC): Error stopping scanner: [org.bluez.Error.InProgress] Operation already in progress
 homeassistant  2023-01-01 23:53:05.702 WARNING (MainThread) [bluetooth_auto_recovery.recover] Getting Bluetooth adapter failed hci0 [B8:27:EB:0E:64:EC] because the system cannot create a bluetooth socket: Unable to open PF_BLUETOOTH socket
 homeassistant  2023-01-01 23:53:05.707 WARNING (MainThread) [bluetooth_auto_recovery.recover] Could not find adapter with mac address B8:27:EB:0E:64:EC or hci0
 homeassistant  2023-01-01 23:53:05.712 WARNING (MainThread) [bluetooth_auto_recovery.recover] Closing Bluetooth adapter hci0 [B8:27:EB:0E:64:EC] failed: 'NoneType' object has no attribute 'detach'

Would be nicer if they didn’t exist.