From c970650abd70e69c98421e14e7eb9a1a85635eff Mon Sep 17 00:00:00 2001 From: Sascha Woitschetzki Date: Mon, 11 Sep 2023 09:26:54 +0200 Subject: [PATCH] add Shutter --- script.js.Shelly.HeatProtection.js | 8 ++++---- script.js.Shelly.Shutter.js | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 script.js.Shelly.Shutter.js diff --git a/script.js.Shelly.HeatProtection.js b/script.js.Shelly.HeatProtection.js index 8d6d786..61e70e5 100644 --- a/script.js.Shelly.HeatProtection.js +++ b/script.js.Shelly.HeatProtection.js @@ -8,11 +8,11 @@ heatProtection(); stopScript("script.js.Shelly.HeatProtection"); function heatProtection() { - allShutters.each(function (shutter, i) { + allShellyWithShutter.each(function (shutter, i) { let shutterName = shutter.split('.')[2]; - if (shuttersOnSouth.includes(shutterName)) { - log("Setting position of " + name + " to " + position + "% for heat protection."); - sendTo("telegram", "send", { text: "Setting position of " + name + " to " + position + "% for heat protection." }); + if (shuttersToAutomate.includes(shutterName)) { + log("Setting position of " + shutterName + " to " + position + "% for heat protection."); + sendTo("telegram", "send", { text: "Setting position of " + shutterName + " to " + position + "% for heat protection." }); setState(shutter, position); } }); diff --git a/script.js.Shelly.Shutter.js b/script.js.Shelly.Shutter.js new file mode 100644 index 0000000..62d1f90 --- /dev/null +++ b/script.js.Shelly.Shutter.js @@ -0,0 +1,27 @@ +const allShellyWithShutter = $('shelly.0.*.Shutter.Position'); +const shuttersToAutomate = ["SHSW-25#84CCA8B0489C#1"]; //Küche + +schedule({ astro: "sunset", shift: 60 }, async function () { + allShellyWithShutter.each(function (shutter, i) { + let shutterName = shutter.split('.')[2]; + if (shuttersToAutomate.includes(shutterName)) { + let textString = '60 min nach Sonnenuntergang, Rollo ' + shutterName + ' runter.'; + console.log(textString); + sendTo("telegram.0", "send", { text: textString }); + setState(shutter, 0); + } + }); +}); + +schedule({ astro: "sunrise", shift: -60 }, async function () { + + allShellyWithShutter.each(function (shutter, i) { + let shutterName = shutter.split('.')[2]; + if (shuttersToAutomate.includes(shutterName)) { + let textString = '60 min vor Sonnenaufgang, Rollo ' + shutterName + ' hoch.'; + console.log(textString); + sendTo("telegram.0", "send", { text: textString }); + setState(shutter, 0); + } + }); +}); \ No newline at end of file