[SwitchBot] Allow to define the press duration

Right now the component allows only to trigger the SwitchBot.

The official SwitchBot API also allows to define the press duration (the time the servo motor stays on the “on” position).

It would be great to be able to define a custom duration when the switch entity is defined:

  - platform: switchbot
    mac: 'aa:bb:cc:dd:ee:ff'
    duration: 10 # duration in seconds

Doing so, we could even use the same SwitchBot in multiple entities, each one with its own duration:

  - platform: switchbot
    name: 'short switch'
    mac: 'aa:bb:cc:dd:ee:ff'
    duration: 1

  - platform: switchbot
    name: 'long switch'
    mac: 'aa:bb:cc:dd:ee:ff'
    duration: 10

I think the duration could be used also for ordinary momentary switches. It would be very nice if HA had this implemented natively.

I second that. I added a switchbot to my PC power switch, I need to be able to press 5 seconds to force kill it, and to then do a simple press without hold to turn it back on

in v3.0 of my esp32 switchbot code you can set bot hold seconds (with password, without password)

the hold seconds is a setting on the bot and needs to be changed before a press action

ESP32 Switchbot MQTT

1 Like