Switchbot Curtain

I have my switchbot curtains connected to my switchbot hub. I followed the integration instructions and both curtain bots are integrated. However, when I want to open or close the curtains, I get the same error:

Bluetooth command failed (code: 2, error: Attribute can’t be read)

Is there another way, or do we depend on the abroadst fix in github as mentioned above ?

Kr,

Bart

I dont even use the hub. Intersting, I just assumed it was a bluetooth issue with my NUC, or just bluetooth in general. Is the hub bluetooth?

Yes, the CurtainBots speak Bluetooth only.
I don’t use the hub but a nearby ESP32 acting as a Bluetooth/WiFi MQTT bridge with the code from @devWaves, there’s nothing better than that for the curtain bots / switch bots!
See this thread

the hub is indeed bluetooth, connected over WLAN to homeassistant

Hmm,
I saw the issue looked to be resolved for some people, but for me I now cannot control my curtains at all.

I removed the device thinking I would readd it, and get this error

Unexpected exception
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/switchbot/config_flow.py", line 89, in async_step_user
    self._discovered_devices = await self._get_switchbots()
  File "/usr/src/homeassistant/homeassistant/components/switchbot/config_flow.py", line 55, in _get_switchbots
    _btle_adv_data = await _btle_connect()
  File "/usr/src/homeassistant/homeassistant/components/switchbot/config_flow.py", line 34, in _btle_connect
    switchbot_devices = await GetSwitchbotDevices().discover()
  File "/usr/local/lib/python3.10/site-packages/switchbot/__init__.py", line 162, in discover
    await devices.start()
  File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/scanner.py", line 88, in start
    self._bus = await MessageBus(bus_type=BusType.SYSTEM).connect()
  File "/usr/local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 122, in __init__
    super().__init__(bus_address, bus_type, ProxyObject)
  File "/usr/local/lib/python3.10/site-packages/dbus_next/message_bus.py", line 85, in __init__
    self._setup_socket()
  File "/usr/local/lib/python3.10/site-packages/dbus_next/message_bus.py", line 575, in _setup_socket
    raise err
  File "/usr/local/lib/python3.10/site-packages/dbus_next/message_bus.py", line 548, in _setup_socket
    self._sock.connect(filename)
FileNotFoundError: [Errno 2] No such file or directory

Found the solution here

I had to make changes to my docker to give it permissions to dbus so bluetooth could work with bleak.

What exactly did you do. It worked just fine but after upgrading to 2022.7.3 (from 2022.6.7) it stopped. I already put:

cap_add net admin to the docker config. I don’t know how to add dbus permissions to the docker.

volumes:
  - /var/run/dbus:/var/run/dbus

I have added this, but don’t know if this is what you mean.

I added this to volumes:

      - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket

Basically the docker container needs permissions to dbus to be able to use bluetooth.
If you need more let me know and I’ll share more of my config

1 Like

my compose file shows the following:

  homeassistant:
    image: homeassistant/home-assistant:latest
    hostname: HomeAssistant
    mem_limit: 4g
    network_mode: host
    container_name: homeassistant
    cap_add:
      - net_admin
#      - sys_admin
    environment:
      - TZ=${TZ}
    logging:
      driver: json-file
      options:
        max-file: ${DOCKERLOGGING_MAXFILE}
        max-size: ${DOCKERLOGGING_MAXSIZE}
    privileged: true
    restart: ${HOMEASSISTANT_RESTART}
    volumes:
      - /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
      - ${DOCKERCONFDIR}/homeassistant:/config
      - ${DOCKERSTORAGEDIR}:/storage

It shows the following error:

Unable to fetch switchbot services data

hmm, interesting. It looks OK to me, but I’ll admit I’m not a docker expert, I’m just good at following steps. haha. So I guess I would check
log on to the host and cd to /var/run/dbus/ and see if system_bus_socket is there?
I’m running a NUC, what hardware are you running?

Also I did remove my switch bot and re add, maybe the new bluetooth driver needed to connect/pair again?

Will try to do this tomorrow, will let you know

Doesn’t seem to work. I’m not a docker expert either, i can, like you, read stuff but it just doesn’t work for me unfortunately.

I’m using a Pi4 and checked, the path is correct to system_bus_socket.

I surely cannot be the only one using a Switchbot curtain with a Pi4 and docker. Hopefully someone can help!

… mmm I really really regret upgrading to 2022.7.x. That being said, when I remove the dbus line I’m getting:

Logger: homeassistant.components.switchbot.config_flow
Source: components/switchbot/config_flow.py:34
Integration: SwitchBot ([documentation](https://www.home-assistant.io/integrations/switchbot), [issues](https://github.com/home-assistant/home-assistant/issues?q=is%3Aissue+is%3Aopen+label%3A%22integration%3A+switchbot%22))
First occurred: 19:54:47 (1 occurrences)
Last logged: 19:54:47

Unexpected exception

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/switchbot/config_flow.py", line 89, in async_step_user self._discovered_devices = await self._get_switchbots() File "/usr/src/homeassistant/homeassistant/components/switchbot/config_flow.py", line 55, in _get_switchbots _btle_adv_data = await _btle_connect() File "/usr/src/homeassistant/homeassistant/components/switchbot/config_flow.py", line 34, in _btle_connect switchbot_devices = await GetSwitchbotDevices().discover() File "/usr/local/lib/python3.10/site-packages/switchbot/__init__.py", line 162, in discover await devices.start() File "/usr/local/lib/python3.10/site-packages/bleak/backends/bluezdbus/scanner.py", line 88, in start self._bus = await MessageBus(bus_type=BusType.SYSTEM).connect() File "/usr/local/lib/python3.10/site-packages/dbus_next/aio/message_bus.py", line 122, in __init__ super().__init__(bus_address, bus_type, ProxyObject) File "/usr/local/lib/python3.10/site-packages/dbus_next/message_bus.py", line 85, in __init__ self._setup_socket() File "/usr/local/lib/python3.10/site-packages/dbus_next/message_bus.py", line 575, in _setup_socket raise err File "/usr/local/lib/python3.10/site-packages/dbus_next/message_bus.py", line 548, in _setup_socket self._sock.connect(filename) FileNotFoundError: [Errno 2] No such file or directory

So for sure the dbus mount does do something. Except it doesnt work. At all. When the line is active it just doesn’t seem to be doing anything. Trying to add results in a ‘can’t connect’ message. I was 99% sure they are in range because they have always worked just fine at the exact same position. Nothing physically has changed. But to be 100% I placed the switchbot right next to the pi4 , same message.

The weird thing is there is no log entry anywhere. No error, no nothing. it just doesn’t work. I can control them by mobile phone and through my old Homey.

I have now installed switchbot-mqtt in a dockercontainer as an alternative. Was a bit of a pain in the butt, but it works. Unfortunately now the curtains get presented by the covers. At least they now work. Hopefully HA will sort their BLE missery.


2022.8 will solve it all, at least, that’s what they are promising. Fingers crossed and see what happens the 3th of aug.

sup guys
love this community, and this discussion is just another good example of it :slight_smile:

need some assistance. for some reason my “open” and “close” buttons are not working properly if the blinds are completely “close” or “open”.
let me elaborate.
buttons, sensor, and even the slider to control the switchbot - works great. however, if the blinds are 100% “open”, for some reason the “open” button on the dashboard is the only one that stays “pressable” (yet pressing it does nothing) while the “close” button is grayed out, and cant be pressed.
the “stop” button is useable as “close” button.
for now, i “reversed” the actions of the buttons - (close button actually open the blinds, and vice versa) but that cant be the “right” way to go…

i’d love some help, if anyone have any experience with this, or knows whats need to be done to fix it…
cheers

Just a heads-up; With 2022.8.0 everything works great! With my compose file mentioned above.

I see in the release note / blog post about 2022.8 they mentioned the direct support of bluetooth, and as such Switchbot integration is now part of the core integration.

SwitchBot - Home Assistant (home-assistant.io)
2022.8: You can fix it! - Home Assistant (home-assistant.io)

So do we still need the container (via mqtt) or any 3rd party integration now that we have 2022.8?
And do we still need the Switchbot hub?

No and no, direct means really direct :muscle::muscle::muscle: love it.

“Really direct” is great however depending where your HA-server and curtain bots are located the distance might be too far for BT. But definitely worth a try!

Agreed! There are solutions for that too. But for now it woekering for me