I have had 2 Switchbot switches that have, in the past, worked on Home Assistant. I have not used these integrations for some time but, because I have now purchased Switchbot Curtain and a Switchbot mini hub, I have revisited my Switchbot integration. It was clear the existing switches were no longer working in Home Assistant and, as I could not find an issue, I decided to follow the Switchbot integration instructions from scratch.
Each time I added the integration, it failed to connect. There are logs that appear to suggest an issue with the Bluetooth adapter. I realise other people have had similar issues but I have not spotted anything that seems to help.
One such log is:
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
I ran bluetoothctl in Terminal and got the following with the MAC redacted:
Agent Registered
[CHG] Controller XX:XX:XX:XX:XX:XX pairable: Yes
My setup is latest Home Assistant on Raspberry PI4. All Switchbot devices are up and working in the android Switchbot app.
I also have the following in my yaml:
device_tracker:
- platform: bluetooth_tracker
new_device_defaults:
track_new_devices: true
switch:
- platform: switchbot
name: Kitchen Light
mac: !secret switchbot_kitchen_mac
password: !secret switchbot_password