Home Assistant OS in KVM with USB Bluetooth adapter passthrough

Hello,

I have Home Assistant OS installed as a virtual machine (virsh) on an Intel NUC 8i5BEH. This has been working quite well for about 6 months now.

I will soon need to add an integration that relies on Bluetooth connectivity (Switchbot) and noticed that the integrated Bluetooth adapter does not passthrough automatically to the guest, so I have no working Bluetooth integration.

I have tried to pass the integrated adapter through by editing my homeassistant VMs XML config.

I found the vendor and product IDs using lsusb:

Bus 001 Device 003: ID 8087:0aaa Intel Corp. Bluetooth 9460/9560 Jefferson Peak (JfP)

Then updated my VM XML config (using virsh edit homeassistant) as follows:

    <!-- within domain.devices -->
    <hostdev mode='subsystem' type='usb' managed='yes'>
      <source>
        <vendor id='0x8087'/>
        <product id='0x0aaa'/>
      </source>
      <address type='usb' bus='0' port='6'/>
    </hostdev>

Unfortunately when restarting the VM with this configuration, the Bluetooth hardware is not detected. After reading some threads, it seems that it’s not possible to pass it through and that I would need to purchase a compatible Bluetooth adapter and then configure that in the XML instead.

I checked the documentation on Bluetooth adapters here: Bluetooth - Home Assistant and purchased a SABRENT BT-UB40 (CSR8510A10) which has just arrived.

I have plugged this into the host and I can see the new vendor and product ID in lsusb:

Bus 001 Device 005: ID 0a12:0001 Cambridge Silicon Radio, Ltd Bluetooth Dongle (HCI mode)

And I have updated the VM XML:

    <!-- within domain.devices -->
    <hostdev mode='subsystem' type='usb' managed='yes'>
      <source>
        <vendor id='0x0a12'/>
        <product id='0x0001'/>
      </source>
      <address type='usb' bus='0' port='6'/>
    </hostdev>

And then rebooted the VM.

Unfortunately Home Assistant OS still does not see this hardware. I am checking in the UI in http://homeassistant.local:8123/config/hardware and cannot see anything for 0a12 or 0001.

I should note that I have been able to successfully passthrough a Zigbee coordinator (zzh) using this same method (updating the XML with the hostdev block and the vendor and product ID for that device) and this was detected in the hardware section immediately, so I believe I am at least doing the XML editing part correctly!

Any advice much appreciated. Hopefully I can get this up and running before my Bluetooth devices arrive next week :sweat_smile:

1 Like

I solved my problem.

I was running virsh reboot homeassistant which was not enough to refresh the configuration.

I had to virsh shutdown homeassistant then virsh start homeassistant.

I am seeing the Bluetooth adapter in Hardware now:

And the integration is setup successfully:
image

Hopefully this helps somebody else in the future!

1 Like

I kinda agree. Just passing along in case someone else sees this thread…

I have an Intel NUC and thought I would give its integrated Bluetooth Adapter a try with HA as a QEMU/KVM Guest.

On the Host:

$lsusb
Bus 003 Device 004: ID 8087:0026 Intel Corp. AX201 Bluetooth

For the host (Ubuntu 22.0.4 w. kernel Linux version 5.19.0-43-generic), the integrated Adapter seems to come up fine in the kernel. From dmesg:

[    3.483669] usbcore: registered new interface driver btusb
[    3.485864] Bluetooth: hci0: Bootloader revision 0.4 build 0 week 30 2018
[    3.486865] Bluetooth: hci0: Device revision is 2
[    3.486867] Bluetooth: hci0: Secure boot is enabled
[    3.486868] Bluetooth: hci0: OTP lock is enabled
[    3.486869] Bluetooth: hci0: API lock is enabled
[    3.486870] Bluetooth: hci0: Debug lock is disabled
[    3.486871] Bluetooth: hci0: Minimum firmware build 1 week 10 2014
[    3.501182] Bluetooth: hci0: Found device firmware: intel/ibt-19-0-4.sfi
[    3.501257] Bluetooth: hci0: Boot Address: 0x24800
[    3.501257] Bluetooth: hci0: Firmware Version: 126-5.22
...
[    5.286948] Bluetooth: hci0: Waiting for firmware download to complete
[    5.287846] Bluetooth: hci0: Firmware loaded in 1744785 usecs
[    5.287902] Bluetooth: hci0: Waiting for device to boot
[    5.302996] Bluetooth: hci0: Device booted in 14766 usecs
[    5.303021] Bluetooth: hci0: Malformed MSFT vendor event: 0x02
[    5.303375] Bluetooth: hci0: Found Intel DDC parameters: intel/ibt-19-0-4.ddc
[    5.305097] Bluetooth: hci0: Applying Intel DDC parameters completed
[    5.305995] Bluetooth: hci0: Firmware revision 0.4 build 126 week 5 2022

However after adding this USB device to HA Guest (much like the xml file shown above, plus doing a shutdown, bringup), HAOS shell dmesg sees:

[    2.951226] usbcore: registered new interface driver 
[    5.015097] Bluetooth: hci0: command 0xfc05 tx timeout
[    5.015097] Bluetooth: hci0: Reading Intel version command failed (-110)

and nothing else happens.

HAOS is running Linux version 6.1.29. It sees the USB device and recognizes it as a BT device, and then starts interrogating it only to fail early on with a simple read of its version, so it becomes a failed Bluetooth device, thus HA never bothers with it.

The following thread seems to suggest that the linux kernel may have issues with these family of Intel devices over a variety of kernel versions. I just don’t know really if this is the problem or not, but I have not yet had any success getting this to work.

One person in that thread said that performing PCI passthrough (instead of USB pass-through) worked for him…but I’m not willing to go through the trouble to try it out (not yet anyway)

1 Like

Hey thanks for the update, I was having the same issue and what a nightmare it was! But a shutdown and the restart solved it, rather than a restart which didn’t solve it.

Cheers for posting your findings.

1 Like

Ah, damn. I wasted so much time.
When I restarted the machine, the VM went into “saved” mode and when I run it, it didn’t just continued, which didn’t help.
When I shut down the VM explicitely, it started working.
One indicator was the MAC was all zeros before (00:00:00:00:00:00) and afterwards it was all non-zeros.

After another reboot it stopped working and I wasn’t yet able to get it working again yet.