Set Button status to off automatically?

Hello :slight_smile:
This question is mainly for switchbot use cases but I guess it can have more applications than that one device.

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.

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

Is there a way to disable that behaviour?

The switchbot (or at least the python library that pilots it) doesn’t report it’s state, so the status in HA is basically always assumed. If you can, pilot the release time by automation and, assuming the switchbot is not triggered by anything else than HA, your reading will be correct.

After digging int the app, it doesn’t seem to be possible to change that.
The bot can only function in 2 modes “Press” and “Press and hold” - after which he goes automatically back to his 0 state.

But since you mentioned they python integratuon, I didn’t mentioned it before but I use the ESP32+MQTT integration for switchbot - my guess here is that the dev of said integration could potentially read it out? Will check on github.
I didn’t mention it before hoping there’d be a universal approach / solution to this.

Actually, this is quite simple, and I actively use it. If you follow the steps I’ve provided below, you can easily do it.

Step - 1 / configuration.yaml

    name: "SwitchBot"
    initial: off
    icon: mdi:bell-ring

Step - 2 / New Script

alias: SwitchBot
  - service: input_boolean.turn_on
    metadata: {}
    data: {}
      entity_id: input_boolean.switchbot
  - type: toggle
    domain: switch
  - service: input_boolean.turn_off
        - input_boolean.switchbot
    data: {}
mode: queued
icon: mdi:bell-ring

If you like, you can add a waiting time to your script. It will work as you wish when you use your script in the relevant place. I hope it helps you. (I know, the person who probably wanted this might not need it anymore, but I thought providing a solution would be helpful for people who still need help in this matter.)

1 Like