core: Switchbot integration error: failed to connect
The problem
During initial setup when you first click the installation you get a ‘Failed to connect’ error.
What version of Home Assistant Core has the issue?
Core-2022.4.4
What was the last working version of Home Assistant Core?
No response
What type of installation are you running?
Home Assistant Core
Integration causing the issue
Switchbot
Link to integration documentation on our website
https://www.home-assistant.io/integrations/switchbot/
Diagnostics information
None
Example YAML snippet
None
Anything in the logs that might be useful for us?
Three error messages in the logs
1. Error scanning for Switchbot devices. Retrying (remaining: 3)
Logger: Switchbot
Source: /usr/local/lib/python3.9/site-packages/switchbot/__init__.py:151
First occurred: 9:04:04 PM (4 occurrences)
Last logged: 9:04:07 PM
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 852, in scan
self.start(passive=passive)
File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 790, in start
self._mgmtCmd("le on")
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 'le on' (code: 17, error: Invalid Index)
2. Error scanning for switch devices
Logger: switchbot
Source: /usr/local/lib/python3.9/site-packages/switchbot/__init__.py:151
First occurred: 9:04:04 PM (4 occurrences)
Last logged: 9:04:07 PM
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 852, in scan
self.start(passive=passive)
File "/usr/local/lib/python3.9/site-packages/bluepy/btle.py", line 790, in start
self._mgmtCmd("le on")
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 'le on' (code: 17, error: Invalid Index)
2. Scanning for Switchbot devices failed. Stop trying
Logger: switchbot
Source: /usr/local/lib/python3.9/site-packages/switchbot/__init__.py:155
First occurred: 9:04:07 PM (1 occurrences)
Last logged: 9:04:07 PM
Scanning for Switchbot devices failed. Stop trying
NoneType: None
Additional information
It was setup before. During my troubleshooting for another problem I uninstalled the integration and tried reinstalling.
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Reactions: 7
- Comments: 112 (59 by maintainers)
Same problem here. Are there any other methods of adding Switchbot devices right now that anybody know of?
@RenierM26 Do you have time to add the new UUID so I can test it?
Maybe we can fix/test it before the new release of HA?Just tested this on the latest version of HA (2022.04.6) using Docker.
At first I was getting this permissions issue (we could make the docs more useful by suggesting rootless BLE access):
After updating my Docker compose (with
cap_add: - NET_ADMIN) to allow the container to manage my Bluetooth adapter, I now see the same error message:Can we add the devices manually through YAML still?
@Gibstick didnt post a hack, its actually PR that might fix the issue? Seems like Switchbot changed how devices are advertised: https://github.com/Danielhiversen/pySwitchbot/pull/48
Could this be the case and also the fix?
I installed it on a raspberry pi 4.
how have you installed HA? If you’re using a python virtual environment the folder and file will be in the directory that you setup the venv.
I don’t have that folder.
I’m not sure if this is a related issue but my switchbot curtain was working great until I updated to firmware version 4.6. After the firmware update it lost communication with the device, tried deleting and adding it back but it fails to detect it now. I have two switchbot smart buttons with firmware versions 4.8 and 4.9, those both continue to work.
Thank you so much… A normal reboot didn’t work, but in #60142 someone mentioned a reboot with unplugging the device HA is running on, and that worked!
@robinvoor @Px3 - it sounds like you guys are running Core installed directly.
Have you had any luck with this proposed fix in another repo (obviously substituting Bluepy with the path to the HA binary)?:
https://github.com/IanHarvey/bluepy/issues/218#issuecomment-350680433
Another solution (and this just worked for me) - reboot the device running Home Assistant:
https://github.com/home-assistant/core/issues/60142#issuecomment-975914938