devWaves / SwitchBot-MQTT-BLE-ESP32

Allows for multiple SwitchBot bots and curtains to be controlled via MQTT sent to ESP32. ESP32 will send BLE commands to switchbots and return MQTT responses to the broker. Also supports Temperature, Motion, Contact sensors
MIT License
539 stars 66 forks source link

Turns on at random? #2

Closed hgelpke closed 3 years ago

hgelpke commented 3 years ago

I got this all setup and it works but the one issue is that the ESP randomly sends the command to the SB for a button push. No external triggers are telling it to do so as far as I can tell.

Might be related to loss/reconnect of wifi but I'm not certain

devWaves commented 3 years ago

can't say that really makes sense based on the way it is coded. It only calls the command once if u send it. Are u republishing on reboot or something?

I cannot reproduce that issue. I only own buttons and thats what u have

What MQTT broker are u using and what is publishing/subscribing the MQTT?

I personally use node-red for mqtt. With whatever tool you use you can watch for mqtt msgs published on switchbotMQTT/# (more specifically switchbotMQTT/control )

if u see 2 press control commands, then that is coming from your setup

if the esp32 loses wifi it will do a rescan on mqtt reconnect, but no control commands are resent

I'm assuming you are using HA. if HA loses wifi it may be republishing on reconnect

devWaves commented 3 years ago

if you are using HA, another user had a similar issue with mosquitto mqtt 5.1.1, they reverted back to their older version and it fixed this issue

this link has workaround if that is the exact issue...https://community.home-assistant.io/t/mosquitto-5-1-1add-on-is-broken/286979/21

hgelpke commented 3 years ago

Thank you

I've re-flashed and it seems good now.

Also may have been the case I printed causing issues.

Wish I could say 100% but I appreciate the work you're doing and the quick response.

devWaves commented 3 years ago

no problem. I'll close the issue for now. can be reopened if needed. im glad others have found this code to be useful