Periodically my Bluetooth SwitchBot hygrometers go offline. HA reports ‘unavailable’. I have to restart the PI to get it working.
I run HA in a docker container.
After many days of trying, I finally found the error in the homeassistant log file:
2023-10-29 03:54:38.070 INFO (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (B8:27:EB:A1:05:AC): Bluetooth scanner has gone quiet for 90s, restarting
2023-10-29 03:54:40.409 WARNING (MainThread) [bluetooth_auto_recovery.recover] Getting Bluetooth adapter failed hci0 [B8:27:EB:A1:05:AC] because the system cannot create a bluetooth socket: Unable to open PF_BLUETOOTH socket
2023-10-29 03:54:40.410 WARNING (MainThread) [bluetooth_auto_recovery.recover] Could not find adapter with mac address B8:27:EB:A1:05:AC or hci0
2023-10-29 03:54:40.411 WARNING (MainThread) [bluetooth_auto_recovery.recover] Closing Bluetooth adapter hci0 [B8:27:EB:A1:05:AC] failed: 'NoneType' object has no attribute 'detach'
2023-10-29 03:54:44.443 ERROR (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (B8:27:EB:A1:05:AC): Failed to restart Bluetooth scanner: hci0 (B8:27:EB:A1:05:AC): Failed to start Bluetooth: [org.bluez.Error.InProgress] Operation already in progress
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/bluetooth/scanner.py", line 223, in _async_start
await self.scanner.start() # type: ignore[no-untyped-call]
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/bleak/__init__.py", line 198, in start
await self._backend.start()
File "/usr/local/lib/python3.11/site-packages/bleak/backends/bluezdbus/scanner.py", line 185, in start
self._stop = await manager.active_scan(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/bleak/backends/bluezdbus/manager.py", line 416, in active_scan
assert_reply(reply)
File "/usr/local/lib/python3.11/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
bleak.exc.BleakDBusError: [org.bluez.Error.InProgress] Operation already in progress
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/bluetooth/scanner.py", line 353, in _async_restart_scanner
await self._async_start()
File "/usr/src/homeassistant/homeassistant/components/bluetooth/scanner.py", line 305, in _async_start
raise ScannerStartError(
homeassistant.components.bluetooth.scanner.ScannerStartError: hci0 (B8:27:EB:A1:05:AC): Failed to start Bluetooth: [org.bluez.Error.InProgress] Operation already in progress
2023-10-29 03:55:08.072 INFO (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (B8:27:EB:A1:05:AC): Bluetooth scanner has gone quiet for 90s, restarting
2023-10-29 03:55:08.075 WARNING (MainThread) [bluetooth_auto_recovery.recover] Getting Bluetooth adapter failed hci0 [B8:27:EB:A1:05:AC] because the system cannot create a bluetooth socket: Unable to open PF_BLUETOOTH socket
2023-10-29 03:55:08.077 WARNING (MainThread) [bluetooth_auto_recovery.recover] Could not find adapter with mac address B8:27:EB:A1:05:AC or hci0
2023-10-29 03:55:08.077 WARNING (MainThread) [bluetooth_auto_recovery.recover] Closing Bluetooth adapter hci0 [B8:27:EB:A1:05:AC] failed: 'NoneType' object has no attribute 'detach'
2023-10-29 03:55:10.423 WARNING (MainThread) [bluetooth_auto_recovery.recover] Getting Bluetooth adapter failed hci0 [B8:27:EB:A1:05:AC] because the system cannot create a bluetooth socket: Unable to open PF_BLUETOOTH socket
2023-10-29 03:55:10.423 WARNING (MainThread) [bluetooth_auto_recovery.recover] Could not find adapter with mac address B8:27:EB:A1:05:AC or hci0
2023-10-29 03:55:10.423 WARNING (MainThread) [bluetooth_auto_recovery.recover] Closing Bluetooth adapter hci0 [B8:27:EB:A1:05:AC] failed: 'NoneType' object has no attribute 'detach'
2023-10-29 03:55:10.434 ERROR (MainThread) [homeassistant.components.bluetooth.scanner] hci0 (B8:27:EB:A1:05:AC): Failed to restart Bluetooth scanner: hci0 (B8:27:EB:A1:05:AC): Failed to start Bluetooth: [org.bluez.Error.InProgress] Operation already in progress
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/bluetooth/scanner.py", line 223, in _async_start
await self.scanner.start() # type: ignore[no-untyped-call]
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/bleak/__init__.py", line 198, in start
await self._backend.start()
File "/usr/local/lib/python3.11/site-packages/bleak/backends/bluezdbus/scanner.py", line 185, in start
self._stop = await manager.active_scan(
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/bleak/backends/bluezdbus/manager.py", line 416, in active_scan
assert_reply(reply)
File "/usr/local/lib/python3.11/site-packages/bleak/backends/bluezdbus/utils.py", line 22, in assert_reply
raise BleakDBusError(reply.error_name, reply.body)
...
repeats
....
Does anyone know how to decode the crypic log messages and point me in the right direction please.
I note this over on GitHub but I can’t really understand it or determine what the fix is…
… and I concur, all my bluetooth worked perfectly with same hardware about 3 years ago. Is this a HA issue? I moved house and only unpacked the pi and setup from clean using latest HA - about a month ago so I have not used HA for about 3 years until now, All this used to work - same B T controller, same I, same SwitcvhBots