core: Unable to add the switchbot integration through UI

The problem

Steps to reproduce:

  1. Click Integrations tab (bottom left)
  2. Click “Add integration”
  3. Search for Switchbot using the search box; select Switchbot
  4. Wait a few seconds, a spinner with text Please wait while SwitchBot is being setup is displayed.
  5. Error popup is is shown with the text below (I use nginx frontend, btw):

I checked the core logs, and I did not see any relevant entries.

Config flow could not be loaded: <html> <head><title>504 Gateway Time-out</title></head> <body> <center><h1>504 Gateway Time-out</h1></center> <hr><center>nginx</center> </body> </html> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page --> <!-- a padding to disable MSIE and Chrome friendly error page -->

What version of Home Assistant Core has the issue?

core-2022.3.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

switchbot

Link to integration documentation on our website

https://www.home-assistant.io/integrations/switchbot/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

No

Additional information

No response

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 18 (4 by maintainers)

Most upvoted comments

Try adding --privileged -v /dev/bus/usb:/dev/bus/usb when running docker. This has solved this issue for me. So you socker script might look like : sudo docker run -id --name=“home-assistant” --privileged --restart on-failure -e “TZ=Asia/Riyadh” --net=host -v /volume1/docker/home-assistant:/config - -v /volume1/docker/shared:/shared -v /var/run/docker.sock:/var/run/docker.sock -v /dev/bus/usb:/dev/bus/usb homeassistant/home-assistant

I have a similar issue. It started happening after upgrading to the latest OS (core-2022.2.9), though I don’t know if it’s related or not.

When trying to add the switchbot via the Android app, I see the message displayed to the OP. A similar message is shown when adding through the desktop interface.

This is what appears in the logs:


Logger: switchbot
Source: /usr/local/lib/python3.9/site-packages/switchbot/__init__.py:421
First occurred: 16:56:38 (4 occurrences)
Last logged: 16:58:08

Switchbot communication failed. Stopping trying

Same here, but with a fresh install using docker. Unable to add the switchbot integration (neither using the app nor the website). Any help appreciated.

Logger: switchbot
Source: /usr/local/lib/python3.9/site-packages/switchbot/__init__.py:151
First occurred: 20:01:25 (4 occurrences)
Last logged: 20:01:29

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: 20, error: Permission Denied)


Logger: switchbot
Source: /usr/local/lib/python3.9/site-packages/switchbot/__init__.py:155
First occurred: 20:01:29 (1 occurrences)
Last logged: 20:01:29

Scanning for Switchbot devices failed. Stop trying