Bluetooth in Docker HA on Raspberry Pi 5

Hi! I am trying to enable Bluetooth integration on my HA Docker container instance running on a Raspberry Pi 5. Whenever I start the HA container with Bluetooth provisioned, my Pi becomes almost unresponsive: Python consumes all the CPU. With homeassistant.components.bluetooth: debug logs on, I can see such an endless flow of Bluetooth advertisement messages related to nearby devices:

2024-02-22 16:32:59.448 DEBUG (MainThread) [homeassistant.components.bluetooth] Triggering bluetooth usb discovery
2024-02-22 16:33:04.452 DEBUG (MainThread) [homeassistant.components.bluetooth] Rediscovered adapters: {'hci0': {'address': '**:**:**:**:**:**', 'sw_version': 'pi', 'hw_version': 'usb:v1D6Bp0246d0542', 'passive_scan': False, 'manufacturer': None, 'product': None, 'vendor_id': None, 'product_id': None}}
2024-02-22 16:33:18.663 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: DE:E6:79:15:38:F6 AdvertisementData(service_data={'0000fe9a-0000-1000-8000-00805f9b34fb': b'\x11\x11\xd5\x7f\xfc\xe8q&\xa1\xf3<\xe2~m\xc6\xd3%\xc2\x01'}, service_uuids=['0000fe9a-0000-1000-8000-00805f9b34fb'], rssi=-79) match: set()
2024-02-22 16:33:18.713 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: FF:FF:FF:FF:FF:FF AdvertisementData(manufacturer_data={76: b'\x02\x15\xe1\xf5N\x02\x1e#D\xe0\x9c=Q.\xb5j\xde\xc9\x00d\x00d\xb9'}, rssi=-87) match: {'ibeacon'}
2024-02-22 16:33:18.825 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: E7:A7:27:B0:A4:97 AdvertisementData(local_name='S17 6302 LE', manufacturer_data={1447: b'\x06\x00\x12 #\x00\xca\x00\x00\x10\x00\x00\x00\x00\x00\x00\x00'}, service_uuids=['0000fe07-0000-1000-8000-00805f9b34fb'], tx_power=0, rssi=-73) match: set()
2024-02-22 16:33:18.826 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: FB:E5:F1:85:E0:CA AdvertisementData(service_data={'0000fe9a-0000-1000-8000-00805f9b34fb': b'\x11\x0b\xc1\x16L_\x9f\x1d\x88\xf5e\xcc;G\x86\x1a\x05\xc2\x03'}, service_uuids=['0000fe9a-0000-1000-8000-00805f9b34fb'], rssi=-89) match: set()
2024-02-22 16:33:18.826 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: 4F:4C:F0:7F:38:67 AdvertisementData(manufacturer_data={76: b'\x10\x05\x10\x1c\xaf\xd7N'}, tx_power=11, rssi=-71) match: set()
2024-02-22 16:33:18.836 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: 78:D0:EE:3A:71:33 AdvertisementData(service_data={'0000fef3-0000-1000-8000-00805f9b34fb': b"J\x17#BEHK\x112\xe5'B\xc5\x8e>,E\xb2BZ\xfc\x8d\xa7\x93\x10jS"}, service_uuids=['0000fef3-0000-1000-8000-00805f9b34fb'], rssi=-84) match: set()
2024-02-22 16:33:18.851 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: F2:86:80:CD:35:E2 AdvertisementData(service_data={'0000fe9a-0000-1000-8000-00805f9b34fb': b'\x11\xc1\xf2\xb2f\x0eYEI\xce\xc0C\xc5\xce\xdd\xdb\x0c\xc2\x03'}, service_uuids=['0000fe9a-0000-1000-8000-00805f9b34fb'], rssi=-81) match: set()
2024-02-22 16:33:18.873 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: DE:E6:79:15:38:F6 AdvertisementData(service_data={'0000fe9a-0000-1000-8000-00805f9b34fb': b'\x11\x11\xd5\x7f\xfc\xe8q&\xa1\xf3<\xe2~m\xc6\xd3%\xc2\x02'}, service_uuids=['0000fe9a-0000-1000-8000-00805f9b34fb'], rssi=-86) match: set()
2024-02-22 16:33:18.877 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: 64:E7:D8:96:A0:A7 AdvertisementData(manufacturer_data={117: b'B\x04\x01\x80nd\xe7\xd8\x96\xa0\xa7f\xe7\xd8\x96\xa0\xa6\x01\x00\x00\x00\x00\x00\x00'}, rssi=-95) match: set()
2024-02-22 16:33:18.910 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: E7:A7:27:B0:A4:97 AdvertisementData(local_name='S17 6302 LE', manufacturer_data={1447: b'\x98\xe7\x82\xaa\xe0\x8c;\xad\xe9'}, service_uuids=['0000fe07-0000-1000-8000-00805f9b34fb'], tx_power=0, rssi=-86) match: set()
2024-02-22 16:33:19.002 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: 54:3A:D6:41:D3:85 AdvertisementData(manufacturer_data={117: b'B\x04\x01\x80nT:\xd6A\xd3\x85V:\xd6A\xd3\x84\x01\x02\x00\x00\x00\x00\x00'}, rssi=-77) match: set()
2024-02-22 16:33:19.084 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: FB:E5:F1:85:E0:CA AdvertisementData(service_data={'0000fe9a-0000-1000-8000-00805f9b34fb': b'\x11\x0b\xc1\x16L_\x9f\x1d\x88\xf5e\xcc;G\x86\x1a\x05\xc2\x01'}, service_uuids=['0000fe9a-0000-1000-8000-00805f9b34fb'], rssi=-82) match: set()
2024-02-22 16:33:19.086 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: E3:79:44:7A:E8:57 AdvertisementData(service_data={'0000fe9a-0000-1000-8000-00805f9b34fb': b'\x11u\x19\x97sl\r\x0e\x18\xdf\xa9\xf1\xb1v\x06b\x03\xc2\x02'}, service_uuids=['0000fe9a-0000-1000-8000-00805f9b34fb'], rssi=-79) match: set()
2024-02-22 16:33:19.262 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: F2:86:80:CD:35:E2 AdvertisementData(service_data={'0000fe9a-0000-1000-8000-00805f9b34fb': b'\x11\xc1\xf2\xb2f\x0eYEI\xce\xc0C\xc5\xce\xdd\xdb\x0c\xc2\x02'}, service_uuids=['0000fe9a-0000-1000-8000-00805f9b34fb'], rssi=-85) match: set()
2024-02-22 16:33:19.373 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: F2:86:80:CD:35:E2 AdvertisementData(service_data={'0000fe9a-0000-1000-8000-00805f9b34fb': b'\x11\xc1\xf2\xb2f\x0eYEI\xce\xc0C\xc5\xce\xdd\xdb\x0c\xc2\x03'}, service_uuids=['0000fe9a-0000-1000-8000-00805f9b34fb'], rssi=-80) match: set()
2024-02-22 16:33:19.415 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: DE:E6:79:15:38:F6 AdvertisementData(service_data={'0000fe9a-0000-1000-8000-00805f9b34fb': b'\x11\x11\xd5\x7f\xfc\xe8q&\xa1\xf3<\xe2~m\xc6\xd3%\xc2\x01'}, service_uuids=['0000fe9a-0000-1000-8000-00805f9b34fb'], rssi=-79) match: set()
2024-02-22 16:33:19.517 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: FB:E5:F1:85:E0:CA AdvertisementData(service_data={'0000fe9a-0000-1000-8000-00805f9b34fb': b'\x11\x0b\xc1\x16L_\x9f\x1d\x88\xf5e\xcc;G\x86\x1a\x05\xc2\x03'}, service_uuids=['0000fe9a-0000-1000-8000-00805f9b34fb'], rssi=-89) match: set()
2024-02-22 16:33:19.739 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: DE:E6:79:15:38:F6 AdvertisementData(service_data={'0000fe9a-0000-1000-8000-00805f9b34fb': b'\x11\x11\xd5\x7f\xfc\xe8q&\xa1\xf3<\xe2~m\xc6\xd3%\xc2\x03'}, service_uuids=['0000fe9a-0000-1000-8000-00805f9b34fb'], rssi=-81) match: set()
2024-02-22 16:33:19.796 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: F2:86:80:CD:35:E2 AdvertisementData(service_data={'0000fe9a-0000-1000-8000-00805f9b34fb': b'\x11\xc1\xf2\xb2f\x0eYEI\xce\xc0C\xc5\xce\xdd\xdb\x0c\xc2\x02'}, service_uuids=['0000fe9a-0000-1000-8000-00805f9b34fb'], rssi=-86) match: set()
2024-02-22 16:33:19.955 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: FB:E5:F1:85:E0:CA AdvertisementData(service_data={'0000fe9a-0000-1000-8000-00805f9b34fb': b'\x11\x0b\xc1\x16L_\x9f\x1d\x88\xf5e\xcc;G\x86\x1a\x05\xc2\x01'}, service_uuids=['0000fe9a-0000-1000-8000-00805f9b34fb'], rssi=-84) match: set()
2024-02-22 16:33:19.959 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: DE:E6:79:15:38:F6 AdvertisementData(service_data={'0000fe9a-0000-1000-8000-00805f9b34fb': b'\x11\x11\xd5\x7f\xfc\xe8q&\xa1\xf3<\xe2~m\xc6\xd3%\xc2\x01'}, service_uuids=['0000fe9a-0000-1000-8000-00805f9b34fb'], rssi=-79) match: set()
2024-02-22 16:33:20.014 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: F2:86:80:CD:35:E2 AdvertisementData(service_data={'0000fe9a-0000-1000-8000-00805f9b34fb': b'\x11\xc1\xf2\xb2f\x0eYEI\xce\xc0C\xc5\xce\xdd\xdb\x0c\xc2\x03'}, service_uuids=['0000fe9a-0000-1000-8000-00805f9b34fb'], rssi=-79) match: set()
2024-02-22 16:33:20.157 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: E3:79:44:7A:E8:57 AdvertisementData(service_data={'0000fe9a-0000-1000-8000-00805f9b34fb': b'\x11u\x19\x97sl\r\x0e\x18\xdf\xa9\xf1\xb1v\x06b\x03\xc2\x03'}, service_uuids=['0000fe9a-0000-1000-8000-00805f9b34fb'], rssi=-82) match: set()
2024-02-22 16:33:20.185 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: FB:E5:F1:85:E0:CA AdvertisementData(service_data={'0000fe9a-0000-1000-8000-00805f9b34fb': b'\x11\x0b\xc1\x16L_\x9f\x1d\x88\xf5e\xcc;G\x86\x1a\x05\xc2\x02'}, service_uuids=['0000fe9a-0000-1000-8000-00805f9b34fb'], rssi=-79) match: set()
2024-02-22 16:33:20.343 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: F2:86:80:CD:35:E2 AdvertisementData(service_data={'0000fe9a-0000-1000-8000-00805f9b34fb': b'\x11\xc1\xf2\xb2f\x0eYEI\xce\xc0C\xc5\xce\xdd\xdb\x0c\xc2\x01'}, service_uuids=['0000fe9a-0000-1000-8000-00805f9b34fb'], rssi=-80) match: set()
2024-02-22 16:33:20.452 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: F2:86:80:CD:35:E2 AdvertisementData(service_data={'0000fe9a-0000-1000-8000-00805f9b34fb': b'\x11\xc1\xf2\xb2f\x0eYEI\xce\xc0C\xc5\xce\xdd\xdb\x0c\xc2\x03'}, service_uuids=['0000fe9a-0000-1000-8000-00805f9b34fb'], rssi=-79) match: set()
2024-02-22 16:33:20.596 DEBUG (MainThread) [homeassistant.components.bluetooth.manager] hci0 (**:**:**:**:**:**) [connectable]: DE:E6:79:15:38:F6 AdvertisementData(service_data={'0000fe9a-0000-1000-8000-00805f9b34fb': b'\x11\x11\xd5\x7f\xfc\xe8q&\xa1\xf3<\xe2~m\xc6\xd3%\xc2\x02'}, service_uuids=['0000fe9a-0000-1000-8000-00805f9b34fb'], rssi=-87) match: set()
...

The same Bluetooth device advertisements for some reason continuously come again and again, consuming most of the CPU. This also blocks HA from accessing any other network resources: cloud integrations report ClientConnectorErrors. Only after stopping the Docker container and disabling Bluetooth (i.e. removing dbus volume) I can run HA normally and check the logs.

I use Raspberry Pi 5 8GB, Debian GNU/Linux 12 (bookworm), Docker 25.0.3, Home Assistant 2024.2.2 (from ghcr.io/home-assistant/home-assistant:latest), BlueZ 5.66-1 and dbus-broker 33-1.

Please let me know if you have any thoughts on why this can happen.

While moving to a spacier SD card, I have reinstalled Raspberry Pi OS and all the relevant tools. This time Bluetooth integration did not cause similar issues. All good now!

1 Like

Hey sergey,

your conclusion is actually wrong nevertheless you help me finding out the issue, as i had the exact same issue.

The problem is not related to raspberry-pi os. It is the home-assistant bluetooth integration that is causing this.

Once i turned off my home-assistant (via docker compose stop) the spam stopped. That is why installing freshly resolved your issue probably. In fact you simple didn’t have home-assistant active on a fresh os.