add Lights

master
Sascha Woitschetzki 2023-09-11 09:18:16 +07:00
parent 3f43588c8e
commit 0182f825a1
2 changed files with 46 additions and 0 deletions

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with BOM under Windows, with no BOM otherwise" />
</project>

@ -0,0 +1,42 @@
function mathRandomInt(a, b) {
if (a > b) {
// Swap a and b to ensure a is smaller.
var c = a;
a = b;
b = c;
}
return Math.floor(Math.random() * (b - a + 1) + a);
}
schedule({ astro: "sunset", shift: 60 }, async function () {
setStateDelayed('shelly.0.SHSW-1#40F520017593#1.Relay0.Switch', true, false, parseInt((((mathRandomInt(300000, 900000))) || "").toString(), 10), false);
setStateDelayed('shelly.0.SHSW-1#40F52001A826#1.Relay0.Switch', true, false, parseInt((((mathRandomInt(300000, 900000))) || "").toString(), 10), false);
setStateDelayed('shelly.0.SHSW-1#E8DB84AA0B84#1.Relay0.Switch', true, false, parseInt((((mathRandomInt(300000, 900000))) || "").toString(), 10), false);
console.log('60 min nach Sonnenuntergang, Lichter an.');
sendTo("telegram.0", "send", { text: '60 min nach Sonnenuntergang, Lichter an.' });
});
schedule({ astro: "sunset", shift: 120 }, async function () {
setStateDelayed('shelly.0.SHSW-1#40F520017593#1.Relay0.Switch', false, false, parseInt((((mathRandomInt(300000, 900000))) || "").toString(), 10), false);
setStateDelayed('shelly.0.SHSW-1#40F52001A826#1.Relay0.Switch', false, false, parseInt((((mathRandomInt(300000, 900000))) || "").toString(), 10), false);
setStateDelayed('shelly.0.SHSW-1#E8DB84AA0B84#1.Relay0.Switch', false, false, parseInt((((mathRandomInt(300000, 900000))) || "").toString(), 10), false);
console.log('300 min nach Sonnenuntergang, Lichter aus.');
sendTo("telegram.0", "send", { text: '120 min nach Sonnenuntergang, Lichter aus.' });
});
schedule({ astro: "sunrise", shift: -120 }, async function () {
setStateDelayed('shelly.0.SHSW-1#40F520017593#1.Relay0.Switch', true, false, parseInt((((mathRandomInt(300000, 900000))) || "").toString(), 10), false);
setStateDelayed('shelly.0.SHSW-1#40F52001A826#1.Relay0.Switch', true, false, parseInt((((mathRandomInt(300000, 900000))) || "").toString(), 10), false);
setStateDelayed('shelly.0.SHSW-1#E8DB84AA0B84#1.Relay0.Switch', true, false, parseInt((((mathRandomInt(300000, 900000))) || "").toString(), 10), false);
console.log('300 min vor Sonnenaufgang, Lichter an.');
sendTo("telegram.0", "send", { text: '120 min vor Sonnenaufgang, Lichter an.' });
});
schedule({ astro: "sunrise", shift: -60 }, async function () {
setStateDelayed('shelly.0.SHSW-1#40F520017593#1.Relay0.Switch', false, false, parseInt((((mathRandomInt(300000, 900000))) || "").toString(), 10), false);
setStateDelayed('shelly.0.SHSW-1#40F52001A826#1.Relay0.Switch', false, false, parseInt((((mathRandomInt(300000, 900000))) || "").toString(), 10), false);
setStateDelayed('shelly.0.SHSW-1#E8DB84AA0B84#1.Relay0.Switch', false, false, parseInt((((mathRandomInt(300000, 900000))) || "").toString(), 10), false);
console.log('60 min vor Sonnenaufgang, Lichter aus.');
sendTo("telegram.0", "send", { text: '60 min vor Sonnenaufgang, Lichter aus.' });
});