add HeatProtection

master
Sascha 2023-09-06 10:51:33 +07:00
parent 1c6e0b0491
commit 71e7762d9e
2 changed files with 35 additions and 0 deletions

@ -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);
}
});
}

@ -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);
});
}