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

In that case, my only guess would be the power supply. If u have it plugged into a PC and it isnt crashing but while plugged into the usb charger it does

any slight power fluctuation could mess things up. Even if the power supply is working

If u have an old 1amp cheapo USB power supply I would suggest trying that instead of the fancy one you have

Thanks devWaves will definitely try that and let you know the result.

Hey, I feel a bit bad writing this, as the work done by @devWaves controlles my switchbot flawlesly for months now (big thank you!). But ever since I switched from the back-then wonky native HA switchbot integration to the mqtt bridge, it bothers me that the ESP32 used for it does nothing else. Itā€™s located in my hifi rack, as there is the closest power source to the heating switch I stuck the SB to, so there would be tons of potential for further usecases with the unused pins (audio source switch, physical volume control for the ancient amp, ā€¦)
Now we have bluetooth proxy support in esphome, and Iā€™m considering trying out to flash the same esp32 with esphome and to give the internal SB integration another try. It does still have the weird illogical way to provide controls (SwitchBot momentary mode, also entity missing?) though.
Anyone from within this thread who already tried to switch back and has a few days/weeks of experience with the setup?
I know, I could just leave the mqtt bridge as it is, and add yet another esp to the hifirack, but it kind of feels redundant.
Cheers!

I switched back when active bluetooth control using proxies became available. Iā€™m back on this ESP32 solution however. The native integration worked for a day before becoming unavailable again. Even the one Switchbot device I never used the ESP32 bridge for as it always worked fine (humidity sensor) started to have connection issues.

Having said that, I think it may be fixed in the latest version. As my Humidity sensor has become stable again. So I may give it another try.

As I currently just to test have both integrations running Iā€™ve tested on occasion if the native one keeps responding and it does. But not as smooth as the ESP32 bridge. For example if I close a curtain and then stop midway, the native version wonā€™t show the open action and lists the curtain as ā€˜openingā€™ for a good half a minute or something. While with the ESP32 bridge I can just close, stop, open right away.

1 Like

hey @Lakini. Donā€™t feel bad, use whatever solution you feel best suits your needs. The esphome bluetooth proxy stuff is really cool but I personally wonā€™t be moving to it anytime soon if ever for multiple reasons

  1. My code supports meshing esp32s for contact/motion/meters . Meshing esp32s provides lightning fast response time comparable to zigbee/zwave. My motion sensors and contacts sensors have basically zero delay

  2. my mesh code handles the situations where duplicate data can be received where one esp32 receives the data faster than the other. Without that you could get a door that goes open, closed, open, closed when it was only opened,closed once in reality

3.Active scanning is turned on only when needed/desired in favor of passive scanning. This saves battery on switchbot devices. From my knowledge the esphome stuff has active scanning on all the time

  1. My esp32 code only relies on MQTT and does not rely on other integrations that could receive breaking changes. If u have a working setup feel free to leave it that way

  2. I am not sure if the switchbot integration handles when a switchbot devices is busy by reading the response the devices sends back. my code does. You can test this by putting a hold value on a bot, and during that hold time try to call the bot from the switchbot integration. The switchbot will accept the command but if busy will just return a busy response. My code will retry on busy

If you only have like one bot or curtain etc I can see how using an esp32 just for that can be ā€œwastefulā€ but the code can accomodate using other sensors and the esp32s pins etc, it just isnt as straight forward as the esphome stuff. Just requires combining some arduino examples into the code. I provided some examples in the forum somewhere

but ya the esphome bluetooth proxy stuff is cool. I only wrote my code because the other options sucked at the time. If I had non switchbot BLE devices I would consider using it

3 Likes

Hi!

Thanks for this! It sounds very promising, but for me, this is very unstable. It takes ages for the commands to go through, and my curtain bots keep becoming unavailable most of the time. The board is right next to the curtains, and my wifi strength is solid. Could it be because of the boards I am using? Iā€™m using this board: https://www.amazon.nl/-/en/gp/product/B07Z83H831

Are there any recommended boards out there I can try with?

Thanks

these are the boards I use and they have been running 24/7 for months. No issues, commands are close to instantaneous SwitchBot bot/curtain/meter/contact/motion MQTT ESP32 bridge - Local control - #790 by devWaves

Thanks! There seem to be a lot of variants there. Will any variant work? I read on your github page that you prefer the WROOM-32U?

Iā€™m using these ones: AZDelivery ESP32 NodeMCU
and find them rocksolid and stable.

Thanks, Iā€™m using these ones from the same brand, and it seems 2 out of the 3 I ordered are unstable. https://www.amazon.nl/gp/product/B07Z83H831

Thatā€™s really odd. Have you contacted the vendor AZDelivery?

Yes, but I will probably be returning these. Good thing I bought from Amazon. I have in the mean time placed an order on Aliexpress for the recommended board (WROOM-32U). I will return all 3 AZ-Delivery boards once I get my Aliexpress order.

Hi! Anyone here experienced contact sensor sometimes missed the IN and the OUT is not functioning at all?

hey @williever do u have it configured in the switchbot app? For ā€˜outā€™ to work on motion then contact, you need to set it up like that in the switchbot app. By default it assume you press the button then exit

Yes, I have configured it by setting up to motion instead of pressing the button. Right now I noticed on the logs saying " * Received message on illegal discovery topic ā€˜homeassistant/binary_sensor/Johnā€™s_Door_Contact_Sensor/bincontact/configā€™. The topic contains not allowed characters. For more information see MQTT Discovery - Home Assistant"

Most likely the apostrophe " ā€™ " is causing the issue . HA and MQTT have character rules

I already updated the names (without space and special characters) few days ago because MQTT doesnā€™t detect the devices but I wonder home assistant still remember this old configuration. I already remove the MQTT and started again prior updating the new names, I even restarted the HA.

Screenshot_20221026-231712

As you can see, the entity uses the updated names.

I have SwitchBot curtains, meter, 2 motion sensor, and 1 door sensor. The motion sensor and door sensor is given free by switchbot for beta testing. I wonder if I got an earlier build of the sensors because the sensors acted weird. For example, the first motion sensor is working perfectly in terms for reporting the motion sensor (detected then wait for clear) but the second motion sensor will report detected and followed by clear immediately even thereā€™s still a motion.

First motion sensor:

Second motion sensor:

Is this the same reason why the contact sensor is not functioning correctly especially the In and Out? Most of the time, it misses the reporting of this two but I regularly get the
Contact and other sensor updates everytime I open or close the door.

I would think the hardware is the same and they just update firmwares, but if you got an early build who knows. That does seem weird one motion works and the other doesnā€™t

if they have firmware updates in the app, do that, but otherwise it might be faulty.

the in out works, but it may not be 100% accurate all the time. My code/esp32 will send whatever the switchbot broadcasts though. You can test out the in out stuff from the switchbot app directly. Create an automation im the switchbot app that opens your curtains on in/out. Devices will need to be close enough together