Switchbot Curtain

Second maybe stupid question. What’s the best way to receive BT MAC address?
I usually used hcitool lescan but there is a lot of MACs without any name.
Is there any pattern for Switchbot Mac address?

you can get them from the switchbot app easily. in the device settings. on ios or android. click on the ellipses (3 dots) top right corner

atm, you will need the switchbot app to setup the bot first. if you want to use press/push mode or on/off mode this is done in the app. same for curtains/meter

I found it. It’s a quite hidden :slight_smile:
In app I found only 1 MAC adres but I have two curtains working together in pair, is it correct?

sorry. no idea about curtains in the app since i dont own them. I blindly coded the curtain and meter changes with the help from @duceduc

yes, You will only need one mac address to run the other in pair. This is my curtain and is setup as a pair. Whatever mac address you see in the red box will be the mac address you use to open/close/pause/position.

Ok perfect. So I have a MAC address, flashed ESP.
ESP is connected to MQTT server, but HA doesn’t see any new device.

MQTT:

1616412696: New connection from 172.17.0.1 on port 1883.             
1616412696: Client ESPMQTT already connected, closing old connection.         
1616412696: New client connected from 172.17.0.1 as ESPMQTT (p2, c1, k60).

Arduino IDE file:

static std::map<std::string, String> allBots = {
  /*{ "switchbotone", "xx:xx:xx:xx:xx:xx" },
  { "switchbottwo", "yy:yy:yy:yy:yy:yy" }*/
};

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> allCurtains = {
  { "curtainone", "XX:XX:XX:XX:XX:XX" }
};

it doesnt create ha devices directly. you need to setup mqtt

how many esp32s are u using? you will need a unique name for each esp32

It’s my first ESP32.

watch for mqtt messages on switchbotMQTT/#

you will see a couple messages from there. whether it failed or succeeded

Sorry but where should I watch messages?
In Mosquitto I have only logs about connectind/disconecting clients.
Is there an option to see logs from ESP32?

I feel a bit stupid asking this but I have added https://github.com/alextud/ha-switchbot-curtain as a custom repo to HACS. I restarted HA and added

cover:
  - platform: switchbot-curtain
    mac: XX:XX:XX:XX:XX:XX

To my configuration.yaml. Now the following error

is showing? What obvious mistake am I making here?

For anyone looking for assistance with the ESP32 option which uses this code

please ask questions here
Forum link

I don’t want to take over this thread. thanks

I think you need a name for each curtains. Something like this.

cover:
  - platform: switchbot-curtain
    name: CR Curtains
    mac: C5:C6:FG:79:22:BC
  - platform: switchbot-curtain
    name: LR Curtains
    mac: E2:23:C5:C1:8P:DD

That does not seem to solve it. Looks like it cannot resolve the dependency?

I am not sure what that error is. You may want to go over to the author and ask there.

@ roaulwoerkom
Also, have you tried adding a log to see if you get any other info of what might happened?

I need to check in more details indeed. Actually, the error seems non-fatal and the Config checker is successful. I also get the curtain to work by simply restarting the complete host. But error persist while
it seems to cause no issues.

I’ve got the same error displayed in visual studio code but I checked config was good and after restart all is working. @duceduc was right with the name for each curtains :wink:

i wish there is a video to do this step by step. totally noob about this.

1 Like

If your curtain device is in bluetooth range to your HA server, this will be the easiest way.