so it looks like switchbot released code for their motion and contact sensor. I don’t own those but am willing to look into making some changes to support them
send me a message if you have either of those and want to test. I haven’t coded the changes yet, but I will try to take a look this weekend
first of all thank you for this great development.
i am not familiar with esp32 and this is my first project to integrate the switchbot curtain into HA. but i’m stuck.
(I did manage to do the test with the board so that the led blinks and I ran a sample program to scan for the WiFi network).
Then I was able to add the different libraries in the arduino IDE, but I don’t know if this is also on the board. However, I can’t find any settings or configuration anywhere to adjust the wifi/mqtt and such as mentioned in step 8… So I think I don’t fully understand a number of things.
Can someone help me describe the steps in more detail? Or give me a hint how to set everything up?
I’ve made all changes to the code, except for one topic:
static std::string mqtt_main_topic = ‘‘switchbot’’; // MQTT main topic
Where can i find this ‘‘topic name’’?
The other code for the bots may remain or should they be removed?
(I only have two switchbot Curtain devices paired)
After that I, upload the code to the board and plug it in with 5v usb?
am I correct when I say that HA will recognize the switchbot curtain instantly?
Or do I need to add other things to HA?
This is a very cool project! I think I am very close to getting it to work. I’ve managed to get a curtainbot set up with my esp32, however, I cant control it all. I’ve tried as many different mqtt commands as I can think of, but I still can’t get the curtainbot to do anything. By looking at my mqtt explorer can you tell me exactly what the command would be for open or close?
in the attributes the rssi = -84 which is not very good signal. place the esp32 closer to the curtains
if u are manually using mqtt commands an open command would be this for you…
topic
switchbot/esp32/curtain/curtainone/set
payload
OPEN
…but with HA you dont need to manually use MQTT like that. With HA MQTT discovery and auto device creation you will get curtain devices that get automatically created for you in HA
reboot the esp32, wait a bit then check your devices in HA. you should see a curtainone device automatically show up, no need to mess with MQTT commands
I actually just found the autodiscovery entities soon after i posted this, ha. It works great! Very cool stuff, man. Just to confirm, we need to set up/calibrate the curtains with the switchbot app correct?
I managed to set up the esp32.
when I look at the logs of my mosquito broker add-on, I see the esp32 connected.
However, I don’t see any new devices detected.
I have the default settings of the add-on and when I go to integrations, the mqtt setting has auto detect on.
how far away is the esp32 from your curtain? devices wont get created if the switchbot isnt detected. if you dont have a plug close by to the curtain you can test by plugging the esp32 into a usb battery so u can get it close to the curtain
send some examples of what you see in mqtt logs.
there are 2 LEDs on the esp32, the power LED (always on) and the other LED. When the esp32 boots up you should see the other LED turn on when MQTT connects. The light will stay on until all devices are found then it turns off. if the light stays on, it cant find the devices or there is a typo in your mac addresses. the further the switchbot is from the esp32, the longer the LED will stay on during the boot scan.
make sure you only have one mac address in the allCurtains list. If there are mac addresses in the other lists, the ESP32 will continue to search for switchbots that arent near you
make sure you pre calibrate and setup the curtain using the switchbot app first before you using this solution. after that you dont need the app anymore
I got it working and very happy with the solution!
I want to improve coverage for my 13 ground floor curtains and install a second ESP32.
Question
Can I have all 13 curtains in the Code of both ESP32s or should I spread (split) them over both of them?
if you have multiple esp32s you can use the same mac on th esp32s BUT you need to ensure they create different devices in HA and the MQTT topics are different. so you would need duplicate devices per esp32.
this is because you dont want a control command to be received by 2+ esp32 and sent 2+ times
best solution is to only use a MAC once over all the esp32s and place the esp32 as close as possible to those MAC devices
for meters you could probably use the same MAC multiple times because it only receives data, it doesnt send/connect to meters
I’ve managed to get a simple switchbot set up with my esp32cam, however, I am not able to control it all. I’ve tried as many different mqtt commands as I can think of, but I still can’t get the switchbot to do anything. TBH, I am new to MQTT, however, by looking at my mqtt explorer:
Can you tell me exactly what the command would be for open or close?
I’m not able to find the device in HA due to autodiscovery.