SwitchBot bot/curtain/meter/contact/motion MQTT ESP32 bridge - Local control

Sorry to hear the NimBLE maintainers did not react on this issue. :worried:

By the way, I was running the MQTT ESP32 bridge on version 6.9 when I decided to update the two Curtain Bots to firmware 4.6.
Apparently with that fw the setup was not working any longer but luckily flashing the ESP32 to version 6.11 brought back functionality.

I will stay away of updating the bot firmware in the future…

Hi guys. I tried to find the solution in the post, but it was not able to do it, also because it’s been become so big. I tried to configure my board following the guides, everything works fine except for the fact that only first command after the boot does work.
After that, the device is still connected but it does not answer to any further press.
I’m trying to control a simple switchbot too far from the Raspberry.
Any clues?

@louca take a look at the issues in github. github issue NimBLE 1.3.8 and above

the issue is caused by using NimBLE version 1.3.8 and above. Use version 1.3.7

cheers

1 Like

so ive just got this sketch up and running but im having issues. It all compiles correctly, and jumps on wifi just fine and starts updating over mqtt. but neither of my switchbots are actually controllable, then affter about 4 minutes they all go unavailable.

gotta give it to the amazon sellers of esp32s… all i ever have to do is open one up and try to program it. its going to pseudo work if at all everytime. the second one i pull out works flawlessly. i wish i had a dollar for every microcontroller ive bought that went bad.

Have you double-checked that your NimBLE-Library is version 1.3.7 and not 1.3.8 or 1.4.0?

You saved my life! Thanks, bro!
Now it’s working flawlessly!

no need it was a faulty esp32. when you buy them in bulk its just a given that 1:5 is gonna be problematic.

Hi All,

Quick question. Do I understand it correctly that there is now a way to control switchbot curtains through ESP32. And if so could that be combines with lets say an ESP32 that is bening used as an air quality sensor?

Hi @330chauf

Yes, you can control Switchbot Curtains and Switchbot Bots with an ESP32 module that has Bluetooth and Wifi together with an Arduino-Sketch from @devWaves over Zigbee2MQTT.

No, you will need to compile and load the Sketch from devWaves to your ESP and it controls only the configured Switchbots. (Taken to low price of these modules simply get another one for your air quality sensor)

You can get the code here on github

Zigbee is not part of whats going on here. MQTT is all that is required

1 Like

Hi everyone,

First off, @devWaves thank you for creating this. I have it mostly set up as I would like it.
It’s just that I’m having the same issues others are having. Sometimes the ESP32 seems to freeze up, the switchbot (curtain) becomes unavailable and I can see the ESP32 has lost connection with my wifi. A reboot brings it back, but only temporarily.

I’ve checked and am using NimBLE 1.3.7.

This is my first time using ESP32 boards so I currently only have 1 (WeMos D1 R32). I’d also gotten 2 DevKit V1’s but those are both DOA so I’m waiting for replacements.
Anything that might help me get it working with the WeMos or is waiting for different/new boards my only/best option?

Cheers

@DutchSoul if you are getting random disconnects try with the esp32 core library v1.0.6. I am suspecting that v2+ still has some issues. From Arduino Boards Manager

if you are using Platform IO, I will have to check what version 1.0.6 correlates to in Platform IO

Just wanted to give thanks for this. I was a fan of the innovative design of the Nest Detect contact sensors, but never bought into that system thank goodness. The SwitchBot version of that concept seemed promising, but a cloud integrated contact, motion, light sensor and button was never going to cut it for me.

Thanks to @kpeyanski for the step by step guide and your wonderful efforts, I’m now on my fourth SwitchBot contact sensor (even though I already have many Aqara and Mijia sensors) and I just added another ESP32 and my first SwitchBot Bot, which I’ve never even considered until you made it possible to control it locally from Home Assistant.

Thank you so much for this, and I do hope you’ll consider also adding the new SwitchBot lock and keypad.

2 Likes

hey @SmartHomePrimer glad this solution works for you and thanks. Ya cloud solutions are a no go for me even if reliable, those servers can be shut down at anytime

Supporting the lock might happen but it will need some documentation in order to get things going

1 Like

Good day
Everything is working great, but I have a problem with my curtains position, when it’s open it’s shows 100% closed and when it’s closed it’s shows 0%. What should I do with that?
Thank you

What do you mean? You can also send a system call to close the curtain to like 30% oder 50%.
It does not always have to be fully open or fully closed. Hence the position information.

I understand this but what I mean is when it’s fully open it’s shows- 100% closed and when it’s fully closed it’s shows 0% open
It’s should be opposite.

@Zenia HA and the switchbot app use the opposite values for open vs closed. Thats just how it has to work if u want to use the HA entities

an HA cover entity uses 0% = closed, 100% = open

in the switchbot app 0% = open, 100% = closed

when you say “it should be opposite” I am assuming you are refering to the way the switchbot app/cloud does it