Bluetooth on Oracle VirtualBox?

How do I add Bluetooth to Hassio on Oracle VirtualBox so I can report on these: https://www.home-assistant.io/components/sensor.mitemp_bt/

I know I have to add bluetooth to it but I’m not sure when it’s running Hassio on a VM. Sorry if this is a noob question but any help would be great.

Any help will make my wife incredibly happy.

Thank you in advance!

2 Likes

Virtual Box is supposed to pass the bluetooth thru to your vm from the host. Seems simple to setup you , just go to settings on virtual machine in virtual box and select usb from the column on left then select the usb type that you have from the top then at the bottom right click the + sign to add a filter so it reconnects when you restart your machine. After clicking + select the bluetooth controller name from your host and then it adds it to the empty box with a check mark. Double click the controller you just added and a window opens with options click the very bottom that says remote and select “any” . close everything up and start your vm after a sec or 2 you should be able to hover over the usb icon at the bottom of the vm window (you will need to start vm in normal mode not headless to see this window) and a popup will show the controler you selected. If running ubuntu you will need to install bluez as well ,so at your linux prompt once booted type sudo apt-get install bluez then restart everything and in theory it should work.
I got it to work and find one device one time and cant get it to work again. But this is the way to set it up from what i have found. If you get it working please post how here.

3 Likes

I have the bluetooth added in but no luck… just shows ‘unknown’.

These are what I ordered: https://www.amazon.com/gp/product/B074TY93JM/ref=ppx_yo_dt_b_asin_title_o06__o00_s00?ie=UTF8&psc=1

I assume it’s not the device that isn’t working.

I have both the MAC addresses in there but everything just says ‘unknown’. :frowning_face:

I just got it working today, not sure exactly what the difference is but I used a dongle as opposed to the onboard Bluetooth. The dongle that I used is available on Amazon by the name of plugable very inexpensive and seems to work exceptional. Funny thing 2 systems One desktop and one laptop both running Windows 10 the dongle works and passes through every single time flawlessly on the laptop but when I try to use it on the desktop it causes all Bluetooth to fail when passing through, again I really don’t know what the difference is I guess I just got lucky and found the perfect storm but I can absolutely confirm that it will work in certain situations. I use the same version of virtualbox as well as drivers for the 2 test machines. Oh I almost forgot I did try this on a Windows 7 laptop with an older dual core AMD processor it recognized the dongle and showed that it was being passed through but would not work in home assistant never would scan. I believe it is due to the Windows 7 Operating System more than anything. Also an important note both Windows 10 machines that I attempted on have updates shutdown and have not been updated in quite some time. Not sure if any of this will be helpful but to sum up it is working on a Sony Vaio i7 laptop with 16GB of RAM and Windows 10 with hass.io running inside of a Docker container on virtualbox.

This is the dongle that I used

https://www.amazon.com/Plugable-Bluetooth-Adapter-Raspberry-Compatible/dp/B009ZIILLI

It is very inexpensive and has excellent range penetrating my brick walls and about 35 ft outside which is perfect for my presence detection scanning hope this helps

Also if running ha on Linux be sure to go to open terminal or a Linux command prompt if running Linux server and install Bluetooth. At prompt type. $ sudo apt install bluetooth

1 Like

Maybe I’ll give this a shot and see.

I’m running the VirtualBox on Windows 10 using VMDK (VMWare Workstation) on their installation website.

I’m not sure if that still requires the linux commands? If so I’m unsure even as to how to run those through HASSIO once it boots up on the VM.

My system is still running and operating as expected Bluetooth scanning is working great. I have no experience with VMware Workstation unfortunately. But I can say my setup seems to be working flawlessly I am very happy. If you decide to give it a shot let me know if you need anything I’ll help if I can.

Do you know of the recommended way to scan for bluetooth devices with hassio? I know the linux commands but clearly you can’t just run those with the command line with hassio…

No need to enter commands.As long as virtual box passes the bt module thru it automaticslly starts scanning about 30 to 60 sec after boot.Once it finds a device the device will be seen at the top of page as a sensor and in known_devices folder as well. Bluetooth devices in known devices will have bt prefix added to there mac address.If i start my hass vm in virtual box normal not headless,…aprox 30 sec after hass loads i can see the scan results start populating the screen.Not sure you have a viewing screen with your setup as that would be where you would have a linux prompt to enter commands as needed, but there are no commands to start hass scanning.just dont forget to add the bluetooth component to your configuration.yaml
You can copy and past it right from home assistants bluetooth component section.
Hope this helps

Yeah it’s bizarre… the built in bluetooth goes from showing up in the device manager on my desktop to disappearing when I start the VM up, which I believe would be a good thing as it then shows in the USB selection that the Realtek Bluetooth Radio is being used by the VM but the bluetooth tracker just gives an error in the home assistant log stating…

Error setting up platform bluetooth_tracker

Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/init.py”, line 183, in async_setup_platform
disc_info)
File “/usr/local/lib/python3.6/concurrent/futures/thread.py”, line 56, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/bluetooth_tracker.py”, line 81, in setup_scanner
for dev in discover_devices():
File “/usr/local/lib/python3.6/site-packages/homeassistant/components/device_tracker/bluetooth_tracker.py”, line 59, in discover_devices
lookup_class=False, device_id=device_id)
File “/usr/local/lib/python3.6/site-packages/bluetooth/bluez.py”, line 26, in discover_devices
device_id = _bt.hci_get_route()
OSError: [Errno 97] Address family not supported by protocol

I just used the bluetooth component in the configuration.yaml file as it states to…

  - platform: bluetooth_tracker

Not sure what’s going on but it’s definitely being used by the VM but nothing is being scanned.

Maybe I’ll try the bluetooth dongle you suggested to see if that for some reason resolves the issue.

I also had realtech as onboard bluetooth and the same errors when trying to use it. I think that is a windows being greedy thing, its not gonna share the adapter. The only way i got mine to work is with the adapter. If you have the same dongle that i listed made by plugable be sure to download and install the correct driver for your system from there website. Remember to download the driver for your physical machine not vm. The dongle will work in a normal environment with windows standard driver that loads when you plug it in but virtual box doesn’t like it for some reason and wont see it, so download and install the standalone drivers for your system then make sure both it and the onboard bluetooth is turned on. For some reason if you turn off bluetooth in windows it disables the dongle as well so they both must be on.
Plug order that worked for me
1.download driver from website
2. turn off onboard bluetooth on physical win 10 machine (win 7 will not work)
3.plugin dongle(if windows sees it let it install drivers as well)
4.Install manufacture driver
5. turn on onboard physical machine bluetooth
6.at this point weird stuff may start happening with both bluetooth devices,ignore it
7.with both bluetooth on and dongle pluged in restart physical machine
Once restarted and fully booted (without virtual box running) open virtual box software and right click on your hass vm then select settings, select usb on left column and click on add + sign at right of empty usb filter box at bottom, select the dongle only from the drop down. Double click this selection and in the window that opens at the botom select “any” from the drop down. save and close then start your virtual machine. Give it plenty of time to boot and if all went right you should be able to hover over the usb icon at the bottom of the vm monitor window and see your dongle listed you should also see a list start propagating that looks like errors but they are the actual bluetooth scans,it says something like “last event is not cmd complete” this will continue as long as hass is running and scanning.
This is all assuming that you are running haas in a virtual box vm on virtual box installed on windows 10
I just removed my bluetooth and reinstalled it using these instructions and is working as expected
Good Luck

1 Like

Thanks, I ordered the dongle shortly ago to give it a whirl and I’ll follow these instructions and report back next week when done… hopefully with positive results. Thanks for all the help with this! I appreciate it!

have you updated linux?
need to
$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo install bluetooth
looks like you may have actually got it to find your local bluetooth but need to update a file or two. Just a guess , i am really new to linux and python, cant hurt to try.
Good luck
don’t forget to restart everything after every change

Will those commands actually run from hassio? Sorry for a noob question but I thought those wouldn’t work unless you were running linux and a VM on there.

I’m using Windows 10 with Oracle VirtualBox with the VMDK image for hassio.

ok disregard , i did not realize you were running hass.os not hass.io
i am not familiar with this but i am downloading and will load it up and take a look

Ok, from what i have read so far the setup that you are using is really limited and striped down. It is geared towards simple stuff and getting started. there is no underlying os so the commands will not work.
I recommend you set aside about an hour and follow this video to the letter and at the end you will have a system that will be able to grow and do things as you learn. Outside that i really do not have any interest in trying to setup hassos . i tried to spin it up in virtual box and immediately ran into problems. I really think if you will follow the video it will open up a whole new world for you. And make it a lot easier to get help.
Good Luck
Buy the way the video is walking you through installing fresh ubuntu server and HASS.IO in Virtual Box running in a docker container. Works really well . I have ran it for about a year now and this is the video i started from, i knew nothing about home assistant or linux at the time.

3 Likes

Sounds great, I’ll check this out. Thank you again!

no problem good luck

1 Like

You sir are great! Thank you very much. This was super simple to setup and get configured.

I’m now seeing the bluetooth polling in the normal start window and guess what… it’s finding the MiFlora sensors and reporting in perfectly now! :slight_smile:

Thanks again for all your help and guidance! I think running Hassio this way is going to be much better going forward!

Awsome! Glad I could help. You will have a ball with that system because most anything you can do in full blown home assistant you can do there as you learn(which is where the real power is) and you also have the addon store full of plug and play plugins that you can just install without ever touching yaml files thanks to HASS.IO and guys like Frenk who makes a large portion of the add ons.ENJOY and have a great weekend. I am ordering some of those sensors for my wife’s garden looks a lot easier than what i had planned.
If you haven’t done i highly recommend you do a snapshot now so that if you mess something up exploring its easy to get back to a working system. I would also clone the vm and store it off the system on a flash drive or other media.

1 Like

so did it actually find and use your onboard bluetooth or did you use a dongle.