42 lines
2.9 KiB
JavaScript
42 lines
2.9 KiB
JavaScript
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.' });
|
|
}); |