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

I got it working, very happy! The mistake was a dumb one: I missed the /* and */ in the code before Curtains. I just changed ‘allBots’ to ‘allCurtains’ and put the mac’s there. Working very well now. Thank you for your help!

cool cool

if you are not using a specific device type (example meter/temp sensor) you will still need the variable for the allMeters map collection but you can either comment out the inside MAC addresses like in my code, or you can set it to an empty map list = { }

so if you dont have button bots, make sure it isnt scanning for the “xx:xx:xx:xx:xx:xx” bot from the default code. it will still work, but the scans will always take the max time because it will never find “xx:xx:xx:xx:xx:xx”

if you only had one curtain…

static std::map<std::string, String> allBots = {};

static std::map<std::string, String> allMeters = {};

static std::map<std::string, String> allCurtains = {
  { "curtainone", "xx:xx:xx:xx:xx:xx" }
};

This should do fine, right?


static std::map<std::string, String> allCurtains = {
  { "curtainone", "d9:d2:ea:17:af:94" },
  { "curtaintwo", "fb:ad:73:cf:25:38" }
};

static std::map<std::string, String> allMeters = {
  /*{ "meterone", "xx:xx:xx:xx:xx:xx" },
    { "metertwo", "yy:yy:yy:yy:yy:yy" }*/
};

static std::map<std::string, String> allBots = {
  /*{ "curtainone", "d9:d2:ea:17:af:94" },
    { "curtaintwo", "fb:ad:73:cf:25:38" }*/
};

yes. all good. order of variables does not matter

new version 0.17

I have added support for bot and curtain passwords

I tested the bot with password, but I would need someone else to test passwords with curtains. Please let me know

Set the password up in the app, then add your password to the Arduino code in 0.17

it will require a new arduino library installed: CRC32 (not to be confused with Arduino_CRC32)

If anyone has a switchbot humidifier and wants to help me test, I can look into implementing it

I can’t find the bluetooth calls required for the humidifier online or github, so I would be somewhat guessing. Unless someone can point me to humidifier documentation

Don’t think there is a password for the curtain bot. I can’t find the tabs for it in the app.

oh… thats weird. I just assumed there would be

maybe someone else can confirm with the app. I looked everywhere, maybe I missed a hidden tab?

cannot error when I tried to compile v.17. doing again now.

with the bot it is straight forward to set a password. weird they wouldnt have that with curtain

yea, I can see the password tab for the bot device. For the curtain, it’s not so apparent or just not there.

Getting error while compiling v.17.

conversion from 'std::map<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >::iterator {aka std::_Rb_tree_iterator<std::pair<const std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> > >}' to non-scalar type 'std::map<std::__cxx11::basic_string<char>, String>::iterator {aka std::_Rb_tree_iterator<std::pair<const std::__cxx11::basic_string<char>, String> >}' requested

make sure you are not copy pasting old settings you configured
allBots should be declared like this… (I changed it in v0.16 for uppercase fix I think)

static std::map<std::string, String> allBots = { … }

but anyways, I guess ill release a v0.18 if curtains dont have password option to remove it. that sux

make sure you are not copy pasting old settings you configured
allBots should be declared like this… (I changed it in v0.16 for uppercase fix I think)

static std::map<std::string,  **String** > allBots = { … }

Ah, I see. Missed a few updates since. I came from v.15. Compiling passed now. I will wait for the v.18.

Have you seen this doc for the humidifier? I think is for the switchbot api though.

ya I dont think that gives me the bluetooth info I need. the requestInfo/rescan make the same ble call for bot/curtain/meter, they all just return different values. my guess is the humidifier would work the same way

the on/off for humidifier may be the same as the bot ( i dont know) , would be easy to try if someone has a humidifier though. just pretend it is a bot and call the bot on/off and see if it works

fyi: the curtain password code doesnt affect anything if you arent using it. Ill fix it later tho

Switchbot developer says the BLE for the humidifier is different.

thanks. hopefully not to different for the humidifier. I guess because it has constant power

v0.18. only bot supports passwords