Switchbot Curtain

I have updated my esp32 code

  • it is now setup to work with “unlimited” devices
  • it works with press/on/off (buttons)
  • it works with open/close/pause (curtains)

I’ve read your guide again and it seems the switchbot hub is needed with this setup? I don’t have the hub to test.

no switchbot hub needed for my esp32 setup. Any smarthub that can do MQTT works.

HA <–(MQTT)–> ESP32 <–(Bluetooth BLE) --> switchbot

1 Like

thanks for this. Reading your guide, i’m not sure if this will work in my situation as all i have is the switchbot hub. I’m also still having issues getting Mosquitto MQTT to work properly on my Qnap Nas. I took a look at the switchbot api solution as well and that was a bit over my head.

I do however have an old smartthings hub laying around somewhere thats not being used. not sure if that would help.

I was hoping there was a solution for HA (in docker on a QNAP NAS) > Switchbot Hub > Switchbot Curatin.

If you don’t mind using the api, which means you’ll need an active internet connection for this to work, it’s quite easy to get it working. I’ve posted instructions here: Switch-Bot API integration - Feature Requests - Home Assistant Community (home-assistant.io)

there are a couple solutions. you just need to decide which one suite your needs. using the switchbot hub is a solution but will always require internet access as mentioned

If you want full local control you need to do it with bluetooth BLE. You can either have your smarthub make the bluetooth calls or have your smarthub call something else, and that something else makes the bluetooth calls.

for me, my main switchbot is too far from my smarthub to be reliable. This is why I wrote the esp32 option. an esp32 cost $5.

my esp32 option avoids the hassle of ensuring the linux box bluetooth is configured correctly. you don’t use the bluetooth on the linux box.

2 Likes

Thank you for your code. I tested it and it is working impressively good.
I noticed a bug with the position of the curtains, which is reported after using requestInfo.
Independently from the state of the curtain it always reports the same position.

yes there is an issue with the curtain and meter values I am hoping to get to that this weekend

the control part should be pretty solid though. I put in a couple fixes recently

I would like to let you know that using your latest version position is reported correctly for switchbot-curtains.

Thank you!

cool thanks. to get the latest value I needed to do a rescan of that specific bluetooth device

when you call requestInfo, it deletes the current device and rescans for it. it will scan max 60 sec, but should only take a sec depending on distance from bot

so you should be able to spam control calls as much as u want. When calling requestInfo tho, depending on how close the devices are, you wont want to spam those calls to often

I might have a better version at some point which doesnt need to rescan. I just havent figured that out yet

for now though the code should work for all switchbot devices bot, curtain, temp sensor

Thank you, I noticed that after some hours (with one requestInfo per hour) the device doesn’t respond any more and needs a power cycle. I should probably avoid sending requestInfo commands.

There is an issue. It does become unresponsive with my latest code, Ill look at it later

new version of my esp32 code is up v0.12. I had to disable requestInfo for a specific device, for now

but you can use the rescan mqtt call instead which will rescan for all devices and provide status. send a payload of how many seconds you want to scan for. it will stop if all devices found before time is up

I tested over the last 2 days and rescan works greatly without crashing. Integration in HASS using MQTT was also flawless. Thank you very much

new version v0.13. rescan is still there, and I think I fixed requestInfo for single device

v0.14 OTA update added

Thank you, I tested and it is working flawlessly. With regard to OTA I can connect to port 80 and login, I will test it at your next release.

@devWaves How works OTA update? Just upload changed .ino file?
I prepared ESP32 to connect Switchbot Curtains that will come today and I wonder if this way I can update ESP32 .

From Arduino, click on sketch-> Export Compiled Binary
A .bin file will be created where the SwitchBot-BLE2MQTT-ESP32.ino is located.
In a browser type in the esp32 local ip address. http://esp32_local_ip
login with the default username(admin) and password(admin) if you have not changed it.
Navigate to the .bin file and click on update.
It should upload to the esp32 in less than 1 minutes.
Done.

1 Like