Bluetooth in VirtualBox on MacMini

Hi,

I just migrated from an Intel Nuc to running Home Assistant in VirtualBox on a MacMini. But I can’t get the bluetooth to work in Home Assistant, anyone have got this setup and solved how to do it? I have tried to but Bluetooth filter as a port without success.

It looks like that macOS won’t release the nativ bluetooth suport to a VM. So I picked on USB Bluetooth adapter up and installed that one and got it to work.

I got and error that USB Bluetooth adaptor not available for pass through to guest OS virtual machine. The 3rd party USB Bluetooth adaptor I plugged into my Mac wasnot available for pass-through to virtual machine guest OS. Error: “Failed to attach” .

If you plug a USB Bluetooth adaptor into a Mac, the default behaviour (it would appear) is now to switch the default bluetooth adaptor in use by the system from the Mac’s built in bluetooth radio to the newly installed USB Bluetooth adaptor.

As USB devices cannot be shared, this means that the USB Bluetooth adaptor is not free for use by a VM host.

To change this behaviour, which is defined by a NVRAM boot argument, open up terminal and enter the following command:

sudo nvram bluetoothHostControllerSwitchBehavior=never

Once I had run this command, and with my VM already running and configured to passthrough the USB device, I plugged in my USB Bluetooth adaptor to the host and it worked.

To reverse this behaviour back, simply run:

‘sudo nvram bluetoothHostControllerSwitchBehavior=always’

2 Likes

Do you know which Bluetooth Dongle you used? I want to pass through bluetooth to an ubuntu VM running home assistant in Docker and can’t pass through my native bluetooth on a mac mini either.

Most (all?) of the bluetooth dongles i’ve found say they don’t work with mac. Maybe this doesn’t matter since i need it to work with Ubuntu but would rather buy the right one

Not real sure, you bought one off shelf at a local tech store, and it works after perfectly after I disable the internal BT on the Mac.

are you running hass in docker? curious to know if you had to include the bluetooth dongle in your docker container as a device or if it just worked.

Getting my dongle from amazon this afternoon so I’m sure i’ll find out either way.

I am running ha in a VirtualBox VM, after I turned off the internal BT it just worked for me.

Hi @Stimo,
I tried your solution several times with 2 different bluetooth dongles and still impossible to get a functional bluetooth in home assistant (nothing appears in /dev/serial/ & no /dev/hci0 or /dev/hci1)
Would it be possible for you to give a detailed description of how you got it working please ?

I’m running Home Assistant 2021.9.4 (Core 6.2) on a Mac Mini mid-2011 (i5) with MacOS High Sierra and VirtualBox 6.1.26

Many thanks !
Thomas

I’m working on Bluetooth access as well but in a standard python VENV on a Mac Mini. HA runs fine on MacOS… why do you guys need VirtualBox?

… to use HAOS version

I finally got the hang of this and switched to UTM running Debian hosted on Mac so I could run a supervised install. If anyone is still looking, I’m able to pass this dongle through.

1 Like