Switchbots Stopped Working

Hi Everyone,

I use the switchbot integration and have my home-assistant connect directly to bots over bluetooth. As of the latest home-assistant or hassio update, none of the bots work. They’ve always been a bit a flaky (takes several attempts, sometimes fails). But as of this update, all the bots fail all the time. Any suggestions? Any help much appreciated.

Here are the versions:

arch	armv7l
chassis	embedded
dev	false
docker	true
docker_version	19.03.11
hassio	true
host_os	HassOS 4.14
installation_type	Home Assistant OS
os_name	Linux
os_version	4.19.127-v7
python_version	3.8.5
supervisor	247
timezone	America/Los_Angeles
version	0.116.4
virtualenv	false

Here’s the config:

- platform: switchbot
  mac: 'C1:C8:XX:XX:XX:XX'
  name: Living Room Light Switch
- platform: switchbot
  mac: 'F2:D2:XX:XX:XX:XX'
  name: Dining Room Light Switch
- platform: switchbot
  mac: 'EF:5D:XX:XX:XX:XX'
  name: Kitchen Light Switch
- platform: switchbot
  mac: 'FB:AF:XX:XX:XX:XX'
  name: Counter Light Switch

All the mac addresses are correct, they were unchanged since they were working. I also confirmed the bots work fine with the Switchbot app (which also connects directly over bluetooth).

Here are the logs:

2020-10-17 12:11:52 DEBUG (SyncWorker_20) [switchbot] Sending command to switchbot 570101
2020-10-17 12:11:52 DEBUG (SyncWorker_20) [switchbot] Connecting to Switchbot...
2020-10-17 12:11:53 DEBUG (SyncWorker_20) [switchbot] Failed connecting to Switchbot.
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/switchbot/__init__.py", line 45, in _connect
    self._device = bluepy.btle.Peripheral(self._mac,
  File "/usr/local/lib/python3.8/site-packages/bluepy/btle.py", line 391, in __init__
    self._connect(deviceAddr, addrType, iface)
  File "/usr/local/lib/python3.8/site-packages/bluepy/btle.py", line 439, in _connect
    raise BTLEDisconnectError("Failed to connect to peripheral %s, addr type: %s" % (addr, addrType), rsp)
bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral XX:XX:XX:XX:XX:XX, addr type: random
2020-10-17 12:11:53 WARNING (SyncWorker_20) [switchbot] Error talking to Switchbot.
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/switchbot/__init__.py", line 92, in _sendcommand
    self._connect()
  File "/usr/local/lib/python3.8/site-packages/switchbot/__init__.py", line 45, in _connect
    self._device = bluepy.btle.Peripheral(self._mac,
  File "/usr/local/lib/python3.8/site-packages/bluepy/btle.py", line 391, in __init__
    self._connect(deviceAddr, addrType, iface)
  File "/usr/local/lib/python3.8/site-packages/bluepy/btle.py", line 439, in _connect
    raise BTLEDisconnectError("Failed to connect to peripheral %s, addr type: %s" % (addr, addrType), rsp)
bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral XX:XX:XX:XX:XX:XX, addr type: random
2020-10-17 12:11:53 WARNING (SyncWorker_20) [switchbot] Cannot connect to Switchbot. Retrying (remaining: 3)...
2020-10-17 12:11:53 DEBUG (SyncWorker_20) [switchbot] Sending command to switchbot 570101
2020-10-17 12:11:53 DEBUG (SyncWorker_20) [switchbot] Connecting to Switchbot...
2020-10-17 12:11:53 DEBUG (SyncWorker_20) [switchbot] Failed connecting to Switchbot.
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/switchbot/__init__.py", line 45, in _connect
    self._device = bluepy.btle.Peripheral(self._mac,
  File "/usr/local/lib/python3.8/site-packages/bluepy/btle.py", line 391, in __init__
    self._connect(deviceAddr, addrType, iface)
  File "/usr/local/lib/python3.8/site-packages/bluepy/btle.py", line 439, in _connect
    raise BTLEDisconnectError("Failed to connect to peripheral %s, addr type: %s" % (addr, addrType), rsp)
bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral XX:XX:XX:XX:XX:XX, addr type: random
2020-10-17 12:11:53 WARNING (SyncWorker_20) [switchbot] Error talking to Switchbot.
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/site-packages/switchbot/__init__.py", line 92, in _sendcommand
    self._connect()
  File "/usr/local/lib/python3.8/site-packages/switchbot/__init__.py", line 45, in _connect
    self._device = bluepy.btle.Peripheral(self._mac,
  File "/usr/local/lib/python3.8/site-packages/bluepy/btle.py", line 391, in __init__
    self._connect(deviceAddr, addrType, iface)
  File "/usr/local/lib/python3.8/site-packages/bluepy/btle.py", line 439, in _connect
    raise BTLEDisconnectError("Failed to connect to peripheral %s, addr type: %s" % (addr, addrType), rsp)
bluepy.btle.BTLEDisconnectError: Failed to connect to peripheral XX:XX:XX:XX:XX:XX, addr type: random

I have three switchbots used directly over Pi3B+ bluetooth with HA OS. After upgrading to HassOS 4.14, ran into the same issue with the switchbots. Manually reverting to 4.13 via cli using ha os update --version "4.13" fixed the issue. Currently running HA 0.116.4 on HA OS 4.13 now with no switchbot issues.

Apart from bluetooth range issues I ran into when initially deploying this, the integration has been pretty stable over the last one year or so I’ve been using it.

Update: Seems there is an issue with Bluetooth on 4.14.

Thanks for response. I’ll try that tonight.

Are you using the bluetooth built into Pi3B+ or did you put in your own dongle? I use the switchbots because the quick/easy in a rental apartment, but it doesn’t work great IMHO. For whatever reason, the switchbot app has always been much more consistent than doing it with HA.

I’m using Bluetooth built-in on the pi3B+. The switchbots are installed in different rooms but within 10m of the pi. Only used the switchbot app for initial setup and capture of mac address.