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

I released a v6.7

When the esp32 boots up, before v6.7 it would call requestSettings for all bots to get the firmware/hold/timers/inverted settings values. This requires connecting to the bot and technically uses battery power. v6.7 will retain the settings values and reuse them on future esp32 boots instead of requesting the values through a connection to the bot. This is a battery optimization for bots

also, I added a standard binary door sensor for the contact sensor HA MQTT discovery

1 Like

v6.7 I added a standard binary sensor for contact. Cheers

Hey all,

Is there some instructions on how to upgrade with visual studio code?

How can I get the new version without overwriting the current config?

Thanks

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