Hi, I have this need
By pressing a button 5 times, you should sequentially activate Input 1 then Input 2 then Input 3 then Input 4 and finally turn everything off
It's possible?
Many thanks for your support
Script for sequential activation of Input 1 / Input 2 / Input 3 / Input 4 / OFF
-
- Shelly 4Pro
-
tonyholy -
29. Mai 2024 um 12:17 -
Unerledigt
-
-
Welcome to the forum!
Please have a look at the embedded script library (in each generation 2 Shelly):
This should meet your requirements!
-
Thank you very much . It was what I was looking for
Could you just tell me how I can change this string to make it work?[0 1 2 3, "off"],
I have to close the loop by turning off all inputs
Thank you again
Code
Alles anzeigenlet CONFIG = { /** * Pick your desired Input to be used for triggering the cycling (note: this input would be changed * to detached!) */ INPUT_ID: 0, /** * List (in the expected order) the operations that you want this script to cycle through. * E.g. [switchId, "on" or "off"] */ CYCLES: [ [0, "on"], [1, "on"], [2, "on"], [3, "on"], [0 1 2 3, "off"], ], }; let currentCycle = 0; let runCycle = function () { let currentOperation = CONFIG.CYCLES[currentCycle]; if (!currentOperation) { currentCycle = 0; currentOperation = CONFIG.CYCLES[currentCycle]; } currentCycle++; Shelly.call("switch.set", { id: JSON.stringify(currentOperation[0]), on: currentOperation[1] === "on", }); }; let setup = function () { Shelly.call( "switch.setconfig", { id: JSON.stringify(CONFIG.INPUT_ID), config: { in_mode: "detached" } }, function () { Shelly.addEventHandler(function (event) { if (event.component === "input:" + JSON.stringify(CONFIG.INPUT_ID)) { if ( event.info.state !== false && event.info.event !== "btn_up" && event.info.event !== "btn_down" ) { runCycle(); } } }, null); } ); }; setup();
-
I’m a novice in scripting, but I would assume the example does the following:
1st press of the (single) button: Turn output 1 on
2nd press: Turn output 2 on, leaving output 1 on
3rd press: Turn output 3 on, leaving output 1 and 2 on
4th press: Turn output 1 to 3 off.
You may alter each of the four lines according to your needs!
-
4th press: Turn output 1 to 3 off.
I added this line of code but it is incorrect
I need a hand to write it correctly