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

the default is 30 sec if not in the list. I fixed a bug where is wasnt doing that. you can add any bot/curtain to that list to override the 30 sec

kind of forgot about adding it back though with 10 sec for those

Sorry, jsut realized that my question about both ways communications was stupid. No the switchbot doesn’t communicated with the esp32. But the esp32, recheck status with the requestInfo. Isn’t that 100% reliable?

Any way i can read that requestInfo in HA?

the esp32 code is reliable at calling the switchbot but a simple example of an issue is calling a bot press command while it is in the middle of doing a press (say it had a hold time of 10 secs and in that 10 sec you called press again). The bot will accept 2 control commanfs but will only actually do one, now your on/off is out of sync

you can watch for the successful command mqtt, just saying it could potentially be wrong

ya that is just apparentely how HA handles curtains. if you look at the issues in the github comments, that was discussed

1 Like

if you are using HA MQTT discovery it does all that for you, calling requestInfo separately will not help

when a bot is in press mode is has no concept of on/off. Think about it if you manually turned on you pool pump with your finger, the switchbot would have no idea you did that. if it did keep a state in press mode, it would still think its off

Thanks, just read the closed issue that is actually mentionning the exact same point that I mentionned here hahaha.

Thanks for your great work. I saw somewhere youre from Canada, I’m from MTL.

Hey! cool. over here in Ottawa

Everyone make sure to also thank @HardcoreWR he did some great work on the HA stuff

Thanks, how do I update my ESP32 to the new version? Do I need to re-upload the code using Arduino IDE?

The best instructions for OTA are these from the program file.

Go to ESP32 IP address in browser. In Arduino IDE menu - Sketch / Export compile Binary. Upload the .bin file with the popup file selector.

You can also plug-in the ESP32 to your computer and upload the code from there.
Don’t forget to change the variables, some of the options have changed so it’s best not to copy and paste.

Thank you for your hard work, I’ve been following this program since it was first posted here and it’s completely fixed my SwitchBot problems. Very happy for MQTT Discovery support.

Wanted to make you aware of something I noticed when upgrading to v2.0 from a version without LED support. My ESP32 (LoLin32) has opposite built-in LED positions (LOW in the code should be HIGH for this device), I changed it in my code after noticing the LED only turning off when scanning. This might need to be added as an option, or at least make others aware of this potential issue.

You’re welcome :slight_smile:

crap. ok. didn’t know different esp32s did that. ok, I will put an update out. thanks for pointing that out

v2.1 fixes the issue mentioned. new variable setting ledHighEqualsON

static bool ledHighEqualsON = true;      // ESP32 board LED ON=HIGH (Default). If your ESP32 is turning OFF on scanning and turning ON while IDLE, then set this value to false 

No problem, thanks for integrating a quick fix.

Hi @devWaves

I am a complete beginner with ESP32 and MQTT. I have one switchbot now. Ordered 4 curtain units also but not yet recieved.

By reading the forum, I somehow managed to flash with SwitchBot-BLE2MQTT-ESP32.ino

Flashed it without issue. In mosquito broker, ESP32 is detected:


New client connected from 192.168.0.13 as switchbot (p2, c1, k60, u’mqtt’).


But now, I don’t know how to check if everything is working properly with Home Assistant. For now, I just want to trigger my switchbot with HA. Probably it’s really simple for you. But I am clueless. Can you please explain me how to do that ?

Thanks

if you have mqtt working and MQTT discovery is turned on in HA then it should be as simple as looking at your devices. you should see a switchbotone automatically added to your devices list. you can add it to your lovelace dashboard from there

use this link github

in HA go to Configuration, then Devices

Hi,

Thanks for your reply. With your help, I have found switchbotone. Inside, I have 3 entities with the name given in switchbot app.

portail Battery 97 %
portail Linkquality -90 rssi
portail_switch

When I click on portail_switch, nothing is happening. The bot is not reacting.

I don’t know what I am doing wrong.

Edit : Actually It worked once. If I press the button again it’s not working. Maybe is there a time limit between each press ?

the esp32 is probably too far from the switchbot. an rssi of -90 means it doesn’t have a good signal

you can call the switchbot as many times as you want, no time limit

if it worked once it sounds like you have it configured correctly

Thanks. It’s strange. Both switchbot and ESP32 are in the same room (around 1m distance). If I move it little bit I am getting -85. Is that normal ? I am using this model : Carte de dĂ©veloppement sans fil ESP32 ESP 32, wi fi, Bluetooth, double cƓur, filtres CP2104, Module d'alimentation 2.4GHz RF pour Nodemcu pour Arduino | AliExpress

Do you know any other model with better coverage ?

Thanks

I believe they should all be mostly the same. Some esp32 have external antenna port. mine doesn’t. the one you listed uses the
cp2104 which is the legit one and not the knockoff

Bluetooth uses 2.4ghz just like many other things. there can be alot of interference on 2.4ghz

my esp32 is plugged in behind my fridge, the metal back of the fridge makes the signal worse, but my highest rssi is -73 and it works fine

with rssi signal strength a value closer to 0 means better signal

try with the esp32 right next to the bot and see what rssi you get, if possible try in another room

if your esp32 or bot is close to your router, or an Rpi using usb3, or zigbee or something using 2.4ghz, you could be getting a bad signal from interference with other stuff

-85 is bad if they are in the same room

Hi devWaves!

Nice work on version 2.1 and Thank you @HardcoreWR - Auto discovery surely makes life easier.

I’ve been playing with 2.1 on one esp32 before moving others to this version. On this one I have 3 bots and a meter attached, after a HA reboot the meter does not refresh thus it stays ‘unavailable’.
Is this a known issue or is there a tweak needed? :slight_smile:
I have tried autoRescan ON and OFF, still no joy.

Lucky for me power to this esp32 is on a smart plug so I can toggle power if away from home and it comes back to life.

Sorry
Also, is it possible to have the ‘mqtt_clientname’ added to the wed ui? having multiple esp’s and working out ip addresses can be a little confusing.

I Appreciate your help.