HA Raspberry Pi 4 Bluetooth not working

Hi folks

Just after Xmas moved my HA from my PC to a dedicated Rpi 4, and yesterday realised that the pi has Bluetooth built in (doh!), so removed the Bluetooth dongle.

Now, Bluetooth isn’t activated with the looks of it?

Any help appreciated.

Logs:
File “/usr/src/homeassistant/homeassistant/components/bluetooth_tracker/device_tracker.py”, line 63, in discover_devices
result = bluetooth.discover_devices(
File “/usr/local/lib/python3.9/site-packages/bluetooth/bluez.py”, line 34, in discover_devices
raise BluetoothError ("error communicating with local "
bluetooth.btcommon.BluetoothError: error communicating with local bluetooth adapter
2022-01-27 09:45:28 ERROR (MainThread) [homeassistant.components.bluetooth_tracker.device_tracker] Error looking up Bluetooth device
Traceback (most recent call last):
File “/usr/local/lib/python3.9/site-packages/bluetooth/bluez.py”, line 30, in discover_devices
results = _bt.hci_inquiry (sock, duration=duration, flush_cache=True,
_bluetooth.error: (110, ‘Operation timed out’)
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/bluetooth_tracker/device_tracker.py”, line 156, in perform_bluetooth_update
devices = await hass.async_add_executor_job(discover_devices, device_id)
File “/usr/local/lib/python3.9/concurrent/futures/thread.py”, line 52, in run
result = self.fn(*self.args, **self.kwargs)
File “/usr/src/homeassistant/homeassistant/components/bluetooth_tracker/device_tracker.py”, line 63, in discover_devices
result = bluetooth.discover_devices(
File “/usr/local/lib/python3.9/site-packages/bluetooth/bluez.py”, line 34, in discover_devices
raise BluetoothError ("error communicating with local "
bluetooth.btcommon.BluetoothError: error communicating with local bluetooth adapter
2022-01-27 09:45:35 ERROR (SyncWorker_20) [switchbot] Error scanning for switchbot devices
Traceback (most recent call last):
File “/usr/local/lib/python3.9/site-packages/switchbot/init.py”, line 147, in discover
devices = bluepy.btle.Scanner(self._interface).scan(
File “/usr/local/lib/python3.9/site-packages/bluepy/btle.py”, line 854, in scan
self.stop()
File “/usr/local/lib/python3.9/site-packages/bluepy/btle.py”, line 803, in stop
self._mgmtCmd(self._cmd()+“end”)
File “/usr/local/lib/python3.9/site-packages/bluepy/btle.py”, line 312, in _mgmtCmd
raise BTLEManagementError(“Failed to execute management command ‘%s’” % (cmd), rsp)
bluepy.btle.BTLEManagementError: Failed to execute management command ‘scanend’ (code: 11, error: Rejected)
2022-01-27 09:45:35 WARNING (SyncWorker_20) [switchbot] Error scanning for Switchbot devices. Retrying (remaining: 3)

The internal bluetooth module might be disabled or it is exposed at another path than the USB dongle device.

Right, I will attempt to do some digging…

According to a post as long as ttyAMA0 is not being used by any other device it should just work - ZigBee and Z-Wave are using other ports, and there is no other dongle attached.

Any suggestions anyone?

FYI: Bluetooth tracker not working in 0.98.x when running HA in Docker on NUC. · Issue #26495 · home-assistant/core · GitHub

Went in via terminal as below, but still no luck…

image

1 Like

In my experiences with a rpi3 the bluetooth is very touchy, so I’m not sure if that carry’s over to the rpi4. I would stick with the bluetooth dongle, and if you have an extension cable that you can plug it into, to get some distance from the rpi4 that will help too, cause the rpi can cause interference.

1 Like

Right, will have ago… Found some other post that says Aeotec Z-Stick causes issues with the bluetooth on pi’s, so that may be a cause.

Will report back…

So… gave up with the Rpi bluetooth and put dongle back in, working again. The Rpi bluetooth does seem not to be 100% with HA looking at the many posts.

1 Like

Yeah going with the dongle is the best bet.

1 Like

Hi, I have a similar problem.
Rpi4, boot from ssd, ubuntu os and home assistant on docker.

When I boot the Bluetooth isn’t active, so obviously, the Bluetooth tracking does not work on HA.

If I try those commands on ubuntu

sudo systemctl disable hciuart.service
sudo systemctl start hciuart.service

the Bluetooth starts and I can make it work even in HA.

I can’t find out what’s the real problem, but at the moment I found this workaround, I need to do this on every reboot.

I found my solution on this post:
https://forums.raspberrypi.com/viewtopic.php?p=1870793&hilit=bluetooth#p1870793

1 Like

I’ve got the same issue. But in my case, internal RPi Bluetooth was working perfectly since 4 years. First on RPi3, then on RPi4 since about 1 year.
I think last HA update broke my bluetooth, no other changes on my hardware or software.

I think an external bluetooth dongle is a bad solution until the root cause is not understand.

1 Like

Not sure if this helps: I recently started using Bluetooth on rPi 4, and it didn’t work.
I then remembered I disabled wifi and Bluetooth when I initially set it up as I didn’t use it back then by adding these lines in /boot/config.txt:

# Disable WiFi
dtoverlay=disable-wifi

# Disable Bluetooth
dtoverlay=disable-bt

After commenting out these lines, Bluetooth is working fine again.

This is a hassOS install.

1 Like

I’ve just moved to a RPi 4 so decided to experiment with the bluetooth for presence detection, so maybe not quite the same as I’ve been starting from scratch with no previous bluetooth, but I thought I’d chip in to see if that’s of any help.
I followed the guide with installing the drivers:-

sudo apt install bluetooth libbluetooth-dev

I also did the Bluetooth_LE install as well although have now commented that out of configuration.yaml, but that also installed drivers and gave rootless access to the bluetooth stack, so again not sure if that made mine work?

sudo apt-get install libcap2-bin
sudo setcap 'cap_net_raw,cap_net_admin+eip' $(readlink -f $(which python3))
sudo setcap 'cap_net_raw+ep' $(readlink -f $(which hcitool))

It took me a while to get the RPi to initially detect my phone bluetooth (hence all the messing round with LE), but after I’d done all that and then restarted the pi whilst having the phone in pairing mode it finally created my known_devices file complete with the phone details etc.

Since then it seems to have been fine.
All that said, I cannot however get the bluetooth_tracker.update service call to do a manual update either from within an automation or from the developer tools directly.

service: bluetooth_tracker.update
data: {}
1 Like

What USB dongle has ppl bought thats worked.

where can I find the /boot/config.txt using terminal server on HA?

1 Like

You either connect to the host with ssh on port 22222

https://developers.home-assistant.io/docs/operating-system/debugging/#ssh-access-to-the-host

or you pop your SSD card in your computer and access the boot partition from windows.

Edit: the boot partition is natively accessable in Windows.