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
549 stars 68 forks source link

Possibility to reset the switchbot switch status in HA? #17

Closed IrealiTY closed 3 years ago

IrealiTY commented 3 years ago

Basically, because the switchbot doesn’t have an ON and OFF state the reporting in the dashboard will sometimes do weird things and not trigger correctly. For those who don’t know, when the switchbot triggers, it’ll press down a button/switch/whatever, and then go back to its original position. This is fine if you use it on a Lightswitch or similar devices that do have a realistic on and off-state by themselves. For use cases though where the button is always in a neutral position (for example Touch-sensitive buttons like on a coffee machine etc) the status will keep changing even though the device that’s being controlled by the switchbot doesn’t really match that status.

Direct example to make it a bit more clear: I use the switchbot on an Intercom device to open the door to our apartment complex. As long as the button is pressed, the entrance door will be unlocked. If I call the automation for it, It will press it, wait for a few seconds (that’s a setting on the switchbot device itself) and then let go. Now Home Assistant will report the status as “ON” and next time I need to use the intercom automation, I’ll need a to use it twice back to back to turn the status back to “OFF” and then to activate it again.

TL;DR: Is it possible to make switches go “OFF” (without triggering any actions) automatically after they had been turned on?

devWaves commented 3 years ago

if I understand correctly, the current version already does that

the esp32 will send state = "OFF" when the bot is in press mode

in HA when using MQTT discovery, the switchbot will go "ON" for split second and will go back to "OFF" as soon as the esp32 gets the mqtt message

you should not need to change the device manually back to off, it does that automatically when the bot is in press mode

when the bot is in switch mode, the esp32 will send either state= "ON", or state= "OFF"

when in press mode the state is always assumed to be OFF

watch for state on \<ESPMQTTTopic>/bot/\<name>/state