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

what light sensor do you have and do you know the standard one people buy? I was planning on getting a light sensor for another project at some point

sounds like a cool idea. I only use my esp32 for bot and it is hidden behind fridge. so mine wont get any light lol

I actually have 2 different ones although one of them is currently in use. The one I have available is 3pin KY 018 Optical Sensitive Resistance Light Detection Photosensitive Sensor Module DIY Kit|Integrated Circuits| - AliExpress while the one in use (but could be repurposed if needed) is TEMT6000 Light Sensor Professional TEMT6000 Light Sensor Module For Arduino|Integrated Circuits| - AliExpress.

Hi devWaves,

On a slightly different note regarding adding features to the esp32 board, is it possible to program the red led, so it isn’t red?
ie…

  • Go green once connected to a wifi network.
  • Flash when activating a bot.

My pcb’s are visible and it would be nice for quick visual feedback.

cheers!

there are 2 leds. the power led and the other one

the color can’t change and you can’t disable the power led without physically removing it

I can make the other one flash and/or turn on though

Oh well, good to know.

Having a long flash on the spare led might be nice to show the pcb received data or executing. :+1:

v1.5 has settings for the onboard led

static bool ledOnBootScan = true;      // Turn on LED during initial boot scan
static bool ledOnScan = true;          // Turn on LED while scanning (non-boot)
static bool ledOnCommand = true;      // Turn on LED while command is processing

Wow! that was quick.
Nice little feature deWaves and Thanks.

github user HardcoreWR has contributed some changes for HA MQTT Discovery

These changes are released in v2.0

1 Like

Cool deWaves, Thanks.

Got my 2 curtain bots working today on V1.5, far more responsive now and working great in the lounge.

I had problems getting the position sensor setup for bot location within HA, ended up using template Sharktamer supplied added to Duceduc’s sensor.yaml.

Any ideas on a sensor template for battery levels? I’m a bit of a amateur at scripting. :slight_smile:

:+1:

might be worth waiting for v2.0

MQTT discovery will do all the devices creation works etc. Battery lvl is there

Awesome! Battery level into HA would be amazing.
Battery longevity on curtain bots is uncertain, be nice to monitor levels especially as there pushing/pulling a heavy load. :grimacing:

Nice to see auto-discovery is on the road!

For the moment I still use the API as money always goes somewhere else than domotic :smiley: but as API does not provide battery status and Switchbot is not enough reactive about API suggestions as soon as it will be OK I will use ESP for my meters.

Hi, thanks for your amazing work. I upload the code correctly and on MQTT Explorer I can see my two switchbots

On HA Developer tools I call the service with {"id":"switchbotone","value":"press"} but nothing happens and I get an error

websocket_api script: Error executing script. Invalid data for call_service at pos 1: value should be a string for dictionary value @ data['payload_template']

EDIT: I missed single quote on the payload ‘{“id”:“switchbotone”,“value”:“press”}’. It works now

Hey there, I must be missing something… this doesn’t generate any new entity… did I misunderstood?
I have the node-red mentioned on this threat up and running. I only own for now a Switchbot Bot.

Also I have a small question. I wanna get the curtain ones. I will most likely need 2 of them for 1 window. How do you setup for the combo? You set it as combo on the app first?

Thanks!

Edit : Solved. My mistake.

Also I have a small question. I wanna get the curtain ones. I will most likely need 2 of them for 1 window. How do you setup for the combo? You set it as combo on the app first?

Yes, it will be configure within the app. Once done, find out which of the 2 mac addresses the app is using for the master and input that mac in the esp32 setting.

just reviewing the MQTT discovery stuff v2.0 will be up today

v2.0 released - HA MQTT Discovery

2 Likes

Thanks a lot for your hard work and fast delivery. v2.0 working like a charm!

One small thing. I have a BOT in press mode… that pushes a regualr on/off button on my pool water heater. It’s perfectly working. I jsut wanted to avoid creating an extra input_boolean in HA to keep status of ON/OFF state of my pool water heater. Since this entity generated by MQTT acts just as a switch it will go ON for a second and back off… so I can’t keep track of the real status of my heater. Any solution for this?

Also is it intended that you got rid of the botScanTime for switchbotone?

Thanks!

you will need a separate device of some type.

When a bot is in switch mode it knows the state, when a bot is in press mode, the state according to the bot never changes

the code currently will return state OFF when in press mode, so you can’t use that

I have my coffee maker also on a zwave plug. This way I can turn the power on and it will always start in the same mode. Maybe you can do something similar. Can you monitor the power draw?

or with another esp device you could look at the power led using a light sensor

It is not something easy do without other hardware because the press has no idea of the state and it wouldn’t be 100% reliable

When you say it’s not reliable 100%. the esp32 and the switchbot comunicates both ways no?
Doesn’t the ESP32 received a confirmation from the Bot saying it completed it’s task? Because if yes, I can jsut create another input_boolean and some Node-red.

Also one last thing, not a big deal by the way, the Curtain position says’s 1% on home assistant and on the switchbot app says 99%, somehow they are reversed. Like I said not a big deal, depens on how you see it 1% open or 99% closed.

Thanks!