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

@exorcist no hub support. There is no documentation or indication that the hub can support BLE commands sent to it, It can only send BLE commands

The hub can currently only be controlled through wifi and api

@eagleforce you should be able to select either the esp32 devkit or the wemos d1 mini

If it compiles and uploads you are good

I donā€™t think it has an onboard LED if I remember correctly

All seems to be working now. The crucial step for me for moving the power cord away from the ESP i.e. no coiled USB cable. Just a very short direct one. I also stood the ESP on end and put the antenna far from the device itself. In combination I seem to be able to reach every device without issue. I also monitored and mapped each switchbot signal before and after a change of direction or orientation of the ESP hub.

@devWaves I selected the WEMOS D1 MINI ESP32. The Quinled have an onboard LED of course.

Worked! Thank you for the help. Now Iā€™ve to setup an MQTT docker container. Should be easy.

onboard status led. It has a power LED

Hello @devWaves, first of all, thanks for the great work.
I have a very noob question. I have an esp8266 at home, can I simply use that one or should i order a new esp32?

Hello there. You will need an esp32 not esp8266. The later does not have bluetooth.

Thanks for the answer!

Commenting for anyone looking for the ā€œerrorLocatingDeviceā€. I was trying to do this late at night and made a silly mistake. I was entering the MAC address of the ESP as displayed by my router into the code, whereas youā€™re supposed to enter the BLE MAC address found in the Switchbot App under that particular device. Silly mistake but I hope this comment helps someone.

This is fantastic, just picked up the WeMos D1 to test this out with the curtain controller!

One question, not sure if itā€™s been mentioned. Does it work with the Blind Tilt? SwitchBot Smart Blind | Roller Blinds, Motorized Window Shades ā€“ SwitchBot US

hey @antmag no it is not setup to work with the blind tilt yet

1 Like

Got an odd problem, Iā€™ve been trying to integrate two contact sensors into HA and the MQTT ESP32 with only pic up one of them at a time. I had sensor 1 up and sensor 2 would not come up in MQTT but I could add it via the bluetooth bridge. I recently reinstalled batteries in the two sensors and now sensor 2 is up and in MQTT but sensor 1 is unavailable.

/* Switchbot Contact Sensor Settings */
static std::map<std::string, std::string> allContactSensors = {
  { "kitchencontact", "d7:2f:19:7d:be:0c" },
  { "frontdoorcontact", "cd:d2:54:18:c5:64" }
};

Iā€™m running on a wemos d1 mini I complied it with Arduino IDE 2.04

Anyone have any thoughts?

Hi all, is it possible to use this with a switchbot keypad? I only need to tell the right code from keypad to alarmo to alarm/disarm but i canā€™t figure a way to ā€œsendā€ that code

With the switchbot integration my keypad is shown as a Plug Mini 91AE with only one sensor for power

I have a Wemos D1 Mini ESP32 but in arduino i donā€™t know the right spot to write the mac address for keypad

hey @PatrickHASS.io make sure you delete all devices in HA before reconfiguring. And try with the contact sensors close to the esp32

I have 4 contact sensors. All good here

hey @jonny_63 no the code does not support the keypad

after a battery change and walking away for about an hour all sensors came up and are working fine now.

hey @devWaves quick question how can I turn the red and blue leds on the esp32? they are annoying :frowning:

Does anyoneā€™s ESP go offline periodically? How to prevent that?

This is a fantastic piece of software! The instructions on Github were spot-on, and worked perfectly. I was able to compile and upload to my ESP32 and it found my Switchbot Contact Sensor like a charm! The biggest issue I had was user error on my part since I donā€™t upload to ESP32 very much - I had to search for how to upload properly: Hold-down the ā€œBOOTā€ button on my ESP32 at the right time.

I really, really like the OTA featureā€¦that makes uploading a new version so very, very easy.

Thank you, devWaves, for creating this code and releasing it. You have really made my week! :grinning:

1 Like

hey @bachoo786 you can most likely only disable one of the LEDs. The blue one. The red/orange LED is to show the esp32 has power and is on, and cannot be disabled without physically removing it

you can use these settings, set them all to false if you dont want to see the blue LED at all

static const bool ledOnBootScan = true;              // Turn on LED during initial boot scan
static const bool ledOnScan = true;                  // Turn on LED while scanning (non-boot)
static const bool ledOnCommand = true;               // Turn on LED while MQTT command is processing. If scanning, LED will blink after scan completes. You may not notice it, there is no delay after scan
1 Like