diff --git a/script.js.Shelly.HeatProtection.js b/script.js.Shelly.HeatProtection.js new file mode 100644 index 0000000..725a744 --- /dev/null +++ b/script.js.Shelly.HeatProtection.js @@ -0,0 +1,19 @@ +//Put all Shutters towards south down to 22% + +const position = 22; +const allShutters = $('shelly.0.*.Shutter.Position'); +const shuttersOnSouth = ["SHSW-25#84CCA8B0D29B#1", "SHSW-25#84CCA8B11690#1", "SHSW-25#84CCA8B15259#1", "SHSW-25#84CCA8B16945#1"]; + +heatProtection(); +stopScript("script.js.Shelly.HeatProtection"); + +function heatProtection() { + allShutters.each(function (shutter, i) { + var name = shutter.split('.')[2]; + if (shuttersOnSouth.includes(name)) { + log("Setting position of " + name + " to " + position + "% for heat protection."); + sendTo("telegram", "send", { text: "Setting position of " + name + " to " + position + "% for heat protection." }); + setState(shutter, position); + } + }); +} \ No newline at end of file diff --git a/script.js.Shelly.RandomPositions.js b/script.js.Shelly.RandomPositions.js new file mode 100644 index 0000000..23ed4a9 --- /dev/null +++ b/script.js.Shelly.RandomPositions.js @@ -0,0 +1,16 @@ +//Close all Shutters + +randomPosition(); +stopScript("script.js.Shelly.CloseAll"); + +function randomIntFromInterval(min, max) { // min and max included + return Math.floor(Math.random() * (max - min + 1) + min) +} + +function randomPosition() { + $("[id=shelly.0.*.Shutter.Position]").each(function (id, i) { + let randomPosition = randomIntFromInterval(0, 100); + log("Setting position of " + id + " to " + randomPosition); + setState(id, randomPosition); + }); +} \ No newline at end of file