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

Hello, how could I integrate switchbot devices connected by zigbee2mqtt to alexa?

I have 4 temperature sensors, 1 bot connected to 2 ESP32. I wish I could control them with alexa.

(sorry for my english…i’m spanish)

Hi @cronox87 this doesnt use zigbee2mqtt, but it sounds like you are using the switchbot esp32 code correct?

if the devices are in home assistant then the question is more towards just settings up HA to work with alexa. Your question is better suited for another topic of hooking up HA to alexa which can be found by searching the forum

Hi @devWaves, thank you for the awesome project. Please share if this could be used for Humidifier and IR devices (through mini hub). Thanks again!

Thanks.

What I have realized is that the ESP32 have little bluetooth range. They have to be very close to the meter. If it is in another room it appears to me at -83rssi/-90rssi and the automations show “Trigger” - “Unavailable”

Is it necessary to mesh between several ESP32? or you can configure an ESP32 for one room, another ESP32 for another room without having mesh, as two individual devices.

I don’t know if I explained well in the previous message.

Is it possible to have 4 ESP32’s as follows (without mesh)

1st esp32 - control bot (active option true)

2nd esp32 - controls two motion sensors (passive option true)

3rd esp32 - 3 temperature sensors (passive option true)

4th esp32 - controls door sensor (active option true)

I need several ESP32 since I have automations that do not work well if the ESP32 is too far from the temperature sensor.

IR devices, no it pr9bably won’t ever work for that as it would require the switchbot hub to support BLE commands and be documented

The humidifier could be supported in the future, but the the BLE documentation isn’t fully available yet I think

yes you don’t need to mesh the esp32s. Meshing will just provide faster response times if a device is close to/between multiple meshed esp32

Setting an esp32 to passive only scan should only be done if you have it in a mesh, because battery status can only be retrieved by an active scan. if you want to use passive scanning mostly, just set the rescanTime and all the active scan time to a really high value

not sure what esp32s you have, but the ones I have the BLE is quite strong. I think some are better then others. I also use external antennas on my main ones which provides good signal strength

I have a problem with automations,

when it has been running for X time they stop working (if the humidity of the sensor is x% between 23:00-05:00 it activates the wifi plug)

the automation shows me this log (in the same minute and second)

turned on
became unavailable

if I press the reset button of the esp32 everything works again

At all times I can see the status updates of the sensors (if the temperature / humidity rises or falls, with a delay of about 4-5 seconds from when the sensor changes until it is shown on the HA screen)

FIXED

Automations fail in HA. In node-red everything works fine

Is the esp32 here likely to work with this?

that should work, but you won’t be able to use the ethernet port for network access. you will need to use wifi. The LEDs for BLE and WIFI won’t work since my code is not setup for those. You can use one of those LED pins for the status LED though

it comes in a nice enclosed package but it is fairly pricey compared to other options

This also assumes that you can flash your own firmware on it using the usb port

1 Like

Hi, is there an option to disable the led light on the esp32?

I have a problem with the curtains. The curtain is displayed in HA, but all sensors are marked as unknown and the curtain turner can be opened or closed via HA. in MQTT Explorer comes from the ESP in alternation “activescanning” and “idle”. Does anyone have any ideas as to what could be causing this?

@devWaves - Just to note, thank you for the work you’ve put in to this.
I’ve been using the code successfully for about 3 months with 5 switchbot devices. I recently added another 5 switchbot devices and the service has now deteriorated significantly. The MQTT status information works fine and seems to be equally as responsive. However whenever I try to execute a call to switch them on or off the ESP unit crashes or becomes unresponsive. The same problem occurs even with the original 5 devices which were working fine.

It seems to be a problem with just the sheer number of devices or the workload on the ESP.

Edit - I just changed the board to entirely different one running ESP32 Wrover. Problem remains. changed power supply too. Perhaps the switchbots are just too far away and signal keeps getting lost. My RSSI range from -85 to -36 dependant on the bot. They are however in clear line of sight from the ESP to the bot. Only a pain of glass seperates them. The bots are outside, perhaps the cold is effecting them?

Any pointers would be gratefully received.

first of all great work @devWaves . appreciate this. So i wanted to ask if you have managed to intgerate the switchbot hub using this . If yes , the IR devices that we can setup in using the hub create virtual device ID with-01 or -02 added after device id of the hub. can those be integrated using this mqtt bridge?

For those that are interested, the inside of a switchbot hub. Looks like a ESP8266 running a seperate RF/Bluetooth board.




3 Likes

Firstly, thanks for all your hard work on this one.

I thought for a moment I had really screwed up yesterday, I’ve been using this for a few months for our bedroom curtains and had never really looked at the switchbot app. yesterday I decided to charge the batteries so checked the app and saw a firmware update…So off we went (without checking this thread first!!) then I found that we had lost control of the curtains from HA. I could still see the position of the curtains in HA but controls would not work.
Anyway, today I downloaded the latest version of the code and installed it through Arduino IDE and hey presto we have working curtains again. So far it seems to be working with the curtain bots running v6.0

1 Like

Hi all
I’m new in esp32 things and received my QuinLED-ESP32-AE last week. I managed to install everything as described. I don’t know which board to select in Arduino IDE. In the esp32 menu there are a lot to choose.
Thank you for the short help
eagleforce

@williever to disable the LED set these to false

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;

@Sportsocke522 you said the curtain can be controlled from HA? in mqtt you should see the status change from idle, activescanning to

{status":"controlling"}

if you are not seeing that then the command is not being sent to the esp32. are you sure you are looking at the esp32 mqtt device and not the BLE switchbot integration device?

@dharvey24 My esp32 has like +16 devices, so number of devices should not be the issue here

-85 rssi is a bad connection. it is possible this device is causing the issue.

also yes the cold from outside can cause issues. Switchbots use lithium battery and lithium does not work well in cold