shelly-script-examples icon indicating copy to clipboard operation
shelly-script-examples copied to clipboard

Delay switching off

Open antatta opened this issue 3 years ago • 1 comments

On the Shelly 1 plus, a script to switch on relay at the first push of the button and at the second push of the button delay the switching off of the relay after 60 seconds. How to do that?

antatta avatar Jan 01 '22 16:01 antatta

I guess it can be achieved using Detached button mode. Button press can be detected using "NotifyEvent" component "input:0". it has an event parameter which contains "single_push", "btn_up" etc: {"component":"input:0", "id":0, "event":"btn_up", "ts":1656519297.38}]} This kind of event handler can be found in this file: https://github.com/ALLTERCO/shelly-script-examples/blob/main/activation-switch.js

This line switches the relay, this is the place where you have to implement some sort of logic and a timer. Shelly.call("Switch.Set", swParams);

enesbcs avatar Jun 29 '22 16:06 enesbcs