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

hey @liminal

“PlatformIO already generates .bin files as part of the compile process… if you browse to the .pioenvs / .pio/build / name-of-env folder of your project, you’ll find firmware.bin.”

go to the IP address of the ESP32 in a browser for OTA updates. Upload the firmware.bin file

cheers

LOL Sorry mate, I should have been more specific. That part I’ve got. I’m talking about downloading the latest version of your software. Or do I just have to clone it and copy the relevant parts of the CPP file every time?

I know you spend a lot of time supporting this. So even if you just tell me what I need to google and I can work it out :slight_smile:

yes if you were on v6.6. you can copy paste your mac addresses and wifi settings. you can copy paste everything from your last upload

between this…

/********** REQUIRED SETTINGS TO CHANGE **********/

and this…

/********** ADVANCED SETTINGS - ONLY NEED TO CHANGE IF YOU WANT TO TWEAK SETTINGS **********/

Thank you, its the first time I’ve had to do this, I’m used to using ESPhome LOL

So clone it again and copy and paste your mac addresses ect and any advanced changes you made to the CPP file. delete the old clone :slight_smile:

Awesome, thank you :slight_smile:

Quick question about entity naming.

If I change the entity name it re-rewrites it at every reboot of the ESP32. This is creating a lot of headaches for me with my automation failing to work with my proper naming convention.

If I name it; bedroom_curtains in the CPP file; it changes the device entity to bedroom_curtains_curtains. If I remove the curtain it renames the curtains correctly, but now the device gets lost with just a name of bedroom (with all the other bedroom devices)

Also the bots add swtich, which makes it really hard to control with Alexa, I have to keep saying computer swtich to turn off the computer.

Can I change this myself somewhere?

Thanks :slight_smile:

in the code the MQTT device discovery messages for curtains are in this method
publishHomeAssistantDiscoveryCurtainConfig

you can change lines like this if you want for the entity names

+ "\"name\":\"" + deviceName + " Curtain\"," +

you can use the above for alexa, or there are others ways to rename how alexa sees devices in HA
forum alexa friendly names

I might have introduced a bug in v6.7. Taking a look. Difficult to reproduce since it needs to sit for hours/days

1 Like

Hi All, what a long and comprehensive topic.

I might be out of place but I have ESP32 with a PMS5003 and DHT in the living room. As well as some curtains and controls by switchbot. I was wondering if using ESPHome there is a way to setup MQTT client to then use the same ESP32 to control the curtains as the switchbot integration is very buggy.

hope it’s ok to post this question here?

hey @330chauf esphome doesn’t support switchbot yet. specifically the part for sending BLE commands to devices. ESPhome currently only works for reading BLE data.

This esp32 code will overwrite anything currently on the esp32 and cant be combined with esphome

Just a note I believe there is a bug in v6.7 when it has been running for a long time the esp32 watchdog timer fails. It should only affect it if you have motion and/or contact sensors though because the esp32 has to scan all the time for those. I am going to fix that in the next couple days

Hi @devWaves thanks for your swift and clear answer. That’s a pity. Hopefully swichbot will soon be implemented. It would be totally nice to have the ESP32 be used for several functionalities in one area of a house. And no wonder I could hardly find something on the subject on their site. :thinking:

The HACS solution with SwitchBot worked really well but has to my knowledge been deprecated and the native integration… well it euh…:wink:

Awesome thank you :slight_smile:

You can use an earlier version, which works fine (albeit no battery report). Drop me a PM and I’ll guide you through (basically you have to download a version before march 7 2021 If my memory is correct).

Can someone please help me with procurement? I am trying to sort of make this into a hobby, but while I have no difficulty with the software part, procurement sucks the life out of me.

I would like to buy a device (probably two) compatible with software, but the “Wemos D1 Mini ESP32” doesn’t make sense to me. There is the ESP32, which is a more powerful version of the ESP8266, but when searching for the Wemos D1 Mini I see there are also 4 different versions of it and I only see ESP8266. So, can someone just refer to a particular device that is fully compatible including a full EAN or otherwise a URL? I am based in The Netherlands.

I looked on AliExpress, but that website makes me want to kill myself. So much data, but nobody that just writes down what I am looking for. Such a mess.

hey @lights_on there are tons of different varieties of ESP32 and basically they should technically all work with this code. You just want to make sure to get one that has a USB plug

the “wemos d1 mini esp32” is a small form factor ESP32 dev board. The ones that I have bought before are from here. aliexpress esp32 d1 mini link

I buy the ones with the CP2104 USB-To-Serial chip. That link offers those and the CH9102 version also. The CH9102 version requires special drivers if you want to use them on a MAC, otherwise they are basically the same

They also make esp32’s with external antennas if you want a stronger signal. Here is a link to the ESP32-WROOM-32U and others dev boards aliexpress

You can buy ESP32s as 1 unit, 5 packs, 10 packs etc usually

I am currently using a QuinLED-ESP32-AE only because I had one and it has the external antenna. It works great

FYI: I have no affiliation with the links provided

I did a quick search on amazon netherlands and there are a ton of esp32s. They just tend to be cheaper on aliexpress, banggood etc

Here is a list of esp32 boards Espressif 32 — PlatformIO latest documentation

Hello,
I just setup the ESP32 bridge for a Switchbot bot and I get a signal strength and battery reading.
But everytime I try to trigger the switch nothing happens.
I looked at the Messages being send and found this:
Message 117 received on switchbot/d1_mini_esp32/bot/switchbotone/status at 8:16 PM:
{
“status”: “failed”,
“value”: 7,
“command”: “ON”
}

I have already moved the ESP Board next to the Switchbot to rule out any connection issues.
Any ideas what could be the issues?
Thanks for all your work.

hey @elmaxador you have a password set on your bot that you either forgot to put in the esp32 code, or it has a typo

error 7 means device is encrypted, wrong password

I am assuming you also don’t have values for timer, firmware and hold secs. These values need the password set correctly also to be retrieved

That certainly helps, but adding an external antenna would only complicate the project risk at this stage. I did watch a YouTube video for adding one (soldering + hot glue needed apparently (I don’t have a tool to apply hot glue right now, but if I have to, I will)), but I really prefer to pay someone money for a prepackaged product than to do too many hacks. The main problem I have is that nobody seems to sell an open-source solution that works offline, so I am forced to do some things myself (even though for this particular bridge you obviously did all the work). Getting a fully working solution is still a challenge.

What if I want an option with a case (or do I have to use an external antenna then), because PCBs in view will just scare people?

I’d have to cross around three walls or so (using the Hub Mini) it was already quite difficult to get signals from everywhere.

the esp32s I listed that use an external antenna don’t need soldering (at least that is 100% true for the quindor esp32, I havent bought the other one). they are already setup for antenna you just need to plug it on and it is very simple. The esp32-cam specifically needs soldering because it has both an onboard antenna and the plug

I am using an old asus router antenna. it looks better then the one the cable came with

OK, I had no idea those existed. I think something else the world needs is a website where you can just input an URL describing some project (e.g. your github URL) and your home address and it would return the easiest/fastest/cheapest way to buy it. If nobody has done that, I might build that one day myself, because that would make such questions like the one I am asking go away.

Same with the external antenna. I probably don’t care which one I buy, as long as it is better than an onboard one.

Choices are nice, but not when the overhead of making a choice is so high.

For example, the quindor esp32 guys could just add an option for buying an external antenna to go with it.

That was the issue. Forgot about the password.
Thanks so much for your help!

I am using these and they work fine. They were delivered in under two weeks.