NEWS
[gelöst] [Blockly] Rollosteuerung bei Hitze
-
Hallo,
ich habe mir hier aus dem Forum eine Idee "geklaut" für die Rollosteuerung bei Hitze, sodass diese nach Wetterdaten >=21 Grad & Sonnig, teils wolkig & heiter, je nach Himmelsrichtungen runter und später wieder raufgehen. Die Wetterdaten für die Himmelsrichtungen frage ich 5 Minuten bevor die Rollos, zu den Himmelsrichtungen zeigen, angetriggert werden. Ich habe das in die Bilder Hitze1 & Hitze2 angehangen, da es nicht auf 1 Bild passte
Hier noch der Scriptblock dazu:
// Erzeuge Zustand Hitze Nord-NordOst createState("javascript.0.Hitze_N-NO", function () { schedule("25 7 * * *", function () { if (getState("yr.0.forecast.day0.temperature_max").val >= 21 && (getState("yr.0.forecast.day0.text").val == 'Schönwetter' || getState("yr.0.forecast.day0.text").val == 'Klarer Himmel' || getState("yr.0.forecast.day0.text").val == 'Teils wolkig')) { setState("javascript.0.Hitze_N-NO"/*javascript.0.Hitze_N-NO*/, true); } else { setState("javascript.0.Hitze_N-NO"/*javascript.0.Hitze_N-NO*/, false); } }); }); // Wohnzimmer & Esszimmer_links schedule("30 7 * * *", function () { if (getState("javascript.0.Hitze_N-NO").val == true) { setState("hm-rpc.1.001118A98B3906.4.LEVEL"/*Rollo_WZ:4.LEVEL*/, 25); setState("hm-rpc.1.001118A98B382F.4.LEVEL"/*Rollo_EZ_links:4.LEVEL*/, 25); } }); schedule("0 11 * * *", function () { if (getState("javascript.0.Hitze_N-NO").val == true) { setState("hm-rpc.1.001118A98B3906.4.LEVEL"/*Rollo_WZ:4.LEVEL*/, 100); setState("hm-rpc.1.001118A98B382F.4.LEVEL"/*Rollo_EZ_links:4.LEVEL*/, 100); } }); // Erzeuge Zustand Hitze_Ost-SüdOst createState("javascript.0.Hitze_O-SO", function () { schedule("55 7 * * *", function () { if (getState("yr.0.forecast.day0.temperature_max").val >= 21 && (getState("yr.0.forecast.day0.text").val == 'Schönwetter' || getState("yr.0.forecast.day0.text").val == 'Klarer Himmel' || getState("yr.0.forecast.day0.text").val == 'Teils wolkig')) { setState("javascript.0.Hitze_O-SO"/*javascript.0.Hitze_O-SO*/, true); } else { setState("javascript.0.Hitze_O-SO"/*javascript.0.Hitze_O-SO*/, false); } }); }); // Esszimmer_rechts & Küche & Yvonne´s Zimmer & Badezimmer schedule("0 8 * * *", function () { if (getState("javascript.0.Hitze_O-SO").val == true) { setState("hm-rpc.1.001118A98B3A5F.4.LEVEL"/*Rollo_EZ_rechts:4.LEVEL*/, 25); setState("hm-rpc.1.001118A98B3947.4.LEVEL"/*Rollo_KUE:4.LEVEL*/, 25); setState("hm-rpc.1.001118A98B390F.4.LEVEL"/*Rollo_YZ:4.LEVEL*/, 25); setState("hm-rpc.1.001118A98B35F7.4.LEVEL"/*Rollo_BZ:4.LEVEL*/, 25); } }); schedule("10 15 * * *", function () { if (getState("javascript.0.Hitze_O-SO").val == true) { setState("hm-rpc.1.001118A98B3A5F.4.LEVEL"/*Rollo_EZ_rechts:4.LEVEL*/, 100); setState("hm-rpc.1.001118A98B3947.4.LEVEL"/*Rollo_KUE:4.LEVEL*/, 100); setState("hm-rpc.1.001118A98B390F.4.LEVEL"/*Rollo_YZ:4.LEVEL*/, 100); setState("hm-rpc.1.001118A98B35F7.4.LEVEL"/*Rollo_BZ:4.LEVEL*/, 100); } }); // Erzeuge Zustand Hitze_Süd-SüdWest createState("javascript.0.Hitze_S-SW", function () { schedule("40 15 * * *", function () { if (getState("yr.0.forecast.day0.temperature_max").val >= 21 && (getState("yr.0.forecast.day0.text").val == 'Schönwetter' || getState("yr.0.forecast.day0.text").val == 'Klarer Himmel' || getState("yr.0.forecast.day0.text").val == 'Teils wolkig')) { setState("javascript.0.Hitze_S-SW"/*javascript.0.Hitze_S-SW*/, true); } else { setState("javascript.0.Hitze_S-SW"/*javascript.0.Hitze_S-SW*/, false); } }); }); // Büro & HWR schedule("45 15 * * *", function () { if (getState("javascript.0.Hitze_S-SW").val == true) { setState("hm-rpc.1.001118A98B3937.4.LEVEL"/*Rollo_BUE:4.LEVEL*/, 25); setState("hm-rpc.1.001118A98B3868.4.LEVEL"/*Rollo_HWR:4.LEVEL*/, 25); } }); schedule("0 18 * * *", function () { if (getState("javascript.0.Hitze_S-SW").val == true) { setState("hm-rpc.1.001118A98B3937.4.LEVEL"/*Rollo_BUE:4.LEVEL*/, 100); setState("hm-rpc.1.001118A98B3868.4.LEVEL"/*Rollo_HWR:4.LEVEL*/, 100); } }); // Erzeuge Zustand Hitze_West-NordWest createState("javascript.0.Hitze_W-NW", function () { schedule("5 17 * * *", function () { if (getState("yr.0.forecast.day0.temperature_max").val >= 21 && (getState("yr.0.forecast.day0.text").val == 'Schönwetter' || getState("yr.0.forecast.day0.text").val == 'Klarer Himmel' || getState("yr.0.forecast.day0.text").val == 'Teils wolkig')) { setState("javascript.0.Hitze_W-NW"/*javascript.0.Hitze_W-NW*/, true); } else { setState("javascript.0.Hitze_W-NW"/*javascript.0.Hitze_W-NW*/, false); } }); }); // Kinderzimmer & Schlafzimmer schedule("10 17 * * *", function () { if (getState("javascript.0.Hitze_W-NW").val == true) { setState("hm-rpc.1.001118A98B35E3.4.LEVEL"/*Rollo_KZ:4.LEVEL*/, 25); setState("hm-rpc.1.001118A98B38B1.4.LEVEL"/*Rollo_SZ:4.LEVEL*/, 25); } });
Nun möchte ich das Script ein wenig agiler machen. Bisher ist es ja wie gesagt so, dass er 5 Minuten vor der anstehenden Steuerung (Rollo_Himmelsrichtungen.jpg). das Wetter abgefragt und der Wert auf True oder False gesetzt wird.
Wie kann ich das Blockly Script steuern, dass er die Wetterdaten regelmäßig (z.B. alle 5 Minuten abfragt) und interaktiv die Rollos dann herunter oder wieder hochfährt.
Ein Beispiel zum IST:
7:25 Uhr -> Abfrage, ob Hitze = True oder False
7:30 Uhr-> Wenn True, dann fahre Rollo_WZ & Rollo_EZ_links auf 25%
11:00 Uhr-> Fahre Rollo_WZ & Rollo_EZ_links auf 100%
(Problem hierbei: Wenn es um z.B. 10:00 Uhr Hitze theoretisch nicht mehr true wäre, bleibt er trotzdem unten, oder auch anders herum, dass wenn es um z.B. 10:00 Uhr plötzlich Hitze = true geben würde, bleiben die Rollos oben auf 100%)
Ein Beispiel zum SOLL:
Prüfe im Zeitraum 7:30 Uhr - 11:00 Uhr-> Hitze True oder False (regelmäßig alle paar Minuten)
Sobald Hitze = True-> Fahre Rollo_WZ & Rollo_EZ_links auf 25% herunter
Sobald Hitze = False-> Fahre Rollo_WZ & Rollo_EZ_links auf 100% herauf
Ich hoffe, ich konnte es einigermaßen verständlich schreiben.
Ich hoffe auf eure Hilfe.
Vielen Dank & Grüße
Modjo
4811_rollo_hitze1.jpg
4811_rollo_hitze2.jpg
4811_rollo_himmelsrichtungen.jpg -
Mir fehlt da irgendwie der ist Zustand der Rollade.
Also wenn 7:00 Hitze fahre Rollade auf 25 Prozent zu.
25 Prozent speicherst du in einer Variablen.
Um 10:00 fragst du ab ob Hitze noch da ist.
Wenn true und die Var = 25 Prozent ist mache nichst, Rollade ist ja schon zu.
Wenn true und die Var = 100 Prozent ist fahre Rollade auf x Prozent zu
Wenn keine Hitze false dann Rollade auffahren.
-
Ist zwar etwas umfangreicher, aber die gewünschten Funktionen hab ich in dem Blockly mit drin:
-
Für alle Interessierten,
ich habe es nun wie folgt am Laufen:
var timeout, timeout2, timeout3, timeout4, timeout5, timeout6, timeout7; // Erzeuge Zustand Hitze Nord-NordOst createState("javascript.0.Hitze_N-NO", function () { schedule("55 6 * * *", function () { if (getState("yr.0.forecast.day0.temperature_max").val >= 21 && (getState("yr.0.forecast.day0.text").val == 'Schönwetter' || getState("yr.0.forecast.day0.text").val == 'Klarer Himmel') || getState("yr.0.forecast.day0.temperature_max").val >= 25 && (getState("yr.0.forecast.day0.text").val != 'Regenschauer' || getState("yr.0.forecast.day0.text").val != 'Gewitter')) { setState("javascript.0.Hitze_N-NO"/*javascript.0.Hitze_N-NO*/, true); } else { setState("javascript.0.Hitze_N-NO"/*javascript.0.Hitze_N-NO*/, false); } }); }); // Wohnzimmer & Esszimmer_links schedule("0 7 * * *", function () { if (getState("javascript.0.Hitze_N-NO").val == true) { setState("hm-rpc.1.001118A98B3906.4.LEVEL"/*Rollo_WZ:4.LEVEL*/, 25); setState("hm-rpc.1.001118A98B382F.4.LEVEL"/*Rollo_EZ_links:4.LEVEL*/, 25); timeout = setTimeout(function () { if (getState("hm-rpc.1.001118A98B3906.0.UNREACH").val == true) { setState("hm-rpc.1.001118A98B3906.4.LEVEL"/*Rollo_WZ:4.LEVEL*/, 25); } if (getState("hm-rpc.1.001118A98B382F.0.UNREACH").val == true) { setState("hm-rpc.1.001118A98B382F.4.LEVEL"/*Rollo_EZ_links:4.LEVEL*/, 25); } }, 60000); } }); schedule("0 11 * * *", function () { if (getState("javascript.0.Hitze_N-NO").val == true) { setState("hm-rpc.1.001118A98B3906.4.LEVEL"/*Rollo_WZ:4.LEVEL*/, 100); setState("hm-rpc.1.001118A98B382F.4.LEVEL"/*Rollo_EZ_links:4.LEVEL*/, 100); timeout2 = setTimeout(function () { if (getState("hm-rpc.1.001118A98B3906.0.UNREACH").val == true) { setState("hm-rpc.1.001118A98B3906.4.LEVEL"/*Rollo_WZ:4.LEVEL*/, 100); } if (getState("hm-rpc.1.001118A98B382F.0.UNREACH").val == true) { setState("hm-rpc.1.001118A98B382F.4.LEVEL"/*Rollo_EZ_links:4.LEVEL*/, 100); } }, 60000); } }); // Erzeuge Zustand Hitze_Ost-SüdOst createState("javascript.0.Hitze_O-SO", function () { schedule("55 7 * * *", function () { if (getState("yr.0.forecast.day0.temperature_max").val >= 21 && (getState("yr.0.forecast.day0.text").val == 'Schönwetter' || getState("yr.0.forecast.day0.text").val == 'Klarer Himmel') || getState("yr.0.forecast.day0.temperature_max").val >= 25 && (getState("yr.0.forecast.day0.text").val != 'Regenschauer' || getState("yr.0.forecast.day0.text").val != 'Gewitter')) { setState("javascript.0.Hitze_O-SO"/*javascript.0.Hitze_O-SO*/, true); } else { setState("javascript.0.Hitze_O-SO"/*javascript.0.Hitze_O-SO*/, false); } }); }); // Esszimmer_rechts & Küche & Yvonne´s Zimmer & Badezimmer schedule("0 8 * * *", function () { if (getState("javascript.0.Hitze_O-SO").val == true) { setState("hm-rpc.1.001118A98B3A5F.4.LEVEL"/*Rollo_EZ_rechts:4.LEVEL*/, 25); setState("hm-rpc.1.001118A98B3947.4.LEVEL"/*Rollo_KUE:4.LEVEL*/, 25); setState("hm-rpc.1.001118A98B390F.4.LEVEL"/*Rollo_YZ:4.LEVEL*/, 25); setState("hm-rpc.1.001118A98B35F7.4.LEVEL"/*Rollo_BZ:4.LEVEL*/, 25); timeout3 = setTimeout(function () { if (getState("hm-rpc.1.001118A98B3A5F.0.UNREACH").val == true) { setState("hm-rpc.1.001118A98B3A5F.4.LEVEL"/*Rollo_EZ_rechts:4.LEVEL*/, 25); } if (getState("hm-rpc.1.001118A98B3947.0.UNREACH").val == true) { setState("hm-rpc.1.001118A98B3947.4.LEVEL"/*Rollo_KUE:4.LEVEL*/, 25); } if (getState("hm-rpc.1.001118A98B390F.0.UNREACH").val == true) { setState("hm-rpc.1.001118A98B390F.4.LEVEL"/*Rollo_YZ:4.LEVEL*/, 25); } if (getState("hm-rpc.1.001118A98B35F7.0.UNREACH").val == true) { setState("hm-rpc.1.001118A98B35F7.4.LEVEL"/*Rollo_BZ:4.LEVEL*/, 25); } }, 60000); } }); schedule("10 15 * * *", function () { if (getState("javascript.0.Hitze_O-SO").val == true) { setState("hm-rpc.1.001118A98B3A5F.4.LEVEL"/*Rollo_EZ_rechts:4.LEVEL*/, 100); setState("hm-rpc.1.001118A98B3947.4.LEVEL"/*Rollo_KUE:4.LEVEL*/, 100); setState("hm-rpc.1.001118A98B390F.4.LEVEL"/*Rollo_YZ:4.LEVEL*/, 100); setState("hm-rpc.1.001118A98B35F7.4.LEVEL"/*Rollo_BZ:4.LEVEL*/, 100); timeout4 = setTimeout(function () { if (getState("hm-rpc.1.001118A98B3A5F.0.UNREACH").val == true) { setState("hm-rpc.1.001118A98B3A5F.4.LEVEL"/*Rollo_EZ_rechts:4.LEVEL*/, 100); } if (getState("hm-rpc.1.001118A98B3947.0.UNREACH").val == true) { setState("hm-rpc.1.001118A98B3947.4.LEVEL"/*Rollo_KUE:4.LEVEL*/, 100); } if (getState("hm-rpc.1.001118A98B390F.0.UNREACH").val == true) { setState("hm-rpc.1.001118A98B390F.4.LEVEL"/*Rollo_YZ:4.LEVEL*/, 100); } if (getState("hm-rpc.1.001118A98B35F7.0.UNREACH").val == true) { setState("hm-rpc.1.001118A98B35F7.4.LEVEL"/*Rollo_BZ:4.LEVEL*/, 100); } }, 60000); } }); // Erzeuge Zustand Hitze_Süd-SüdWest createState("javascript.0.Hitze_S-SW", function () { schedule("40 15 * * *", function () { if (getState("yr.0.forecast.day0.temperature_actual").val >= 21 && (getState("yr.0.forecast.day0.text").val == 'Schönwetter' || getState("yr.0.forecast.day0.text").val == 'Klarer Himmel') || getState("yr.0.forecast.day0.temperature_actual").val >= 25 && (getState("yr.0.forecast.day0.text").val != 'Regenschauer' || getState("yr.0.forecast.day0.text").val != 'Gewitter')) { setState("javascript.0.Hitze_S-SW"/*javascript.0.Hitze_S-SW*/, true); } else { setState("javascript.0.Hitze_S-SW"/*javascript.0.Hitze_S-SW*/, false); } }); }); // Büro & HWR schedule("45 15 * * *", function () { if (getState("javascript.0.Hitze_S-SW").val == true) { setState("hm-rpc.1.001118A98B3937.4.LEVEL"/*Rollo_BUE:4.LEVEL*/, 25); setState("hm-rpc.1.001118A98B3868.4.LEVEL"/*Rollo_HWR:4.LEVEL*/, 25); timeout5 = setTimeout(function () { if (getState("hm-rpc.1.001118A98B3937.0.UNREACH").val == true) { setState("hm-rpc.1.001118A98B3937.4.LEVEL"/*Rollo_BUE:4.LEVEL*/, 25); } if (getState("hm-rpc.1.001118A98B3868.0.UNREACH").val == true) { setState("hm-rpc.1.001118A98B3868.4.LEVEL"/*Rollo_HWR:4.LEVEL*/, 25); } }, 60000); } }); schedule("10 20 * * *", function () { if (getState("javascript.0.Hitze_S-SW").val == true) { setState("hm-rpc.1.001118A98B3937.4.LEVEL"/*Rollo_BUE:4.LEVEL*/, 100); setState("hm-rpc.1.001118A98B3868.4.LEVEL"/*Rollo_HWR:4.LEVEL*/, 100); timeout6 = setTimeout(function () { if (getState("hm-rpc.1.001118A98B3937.0.UNREACH").val == true) { setState("hm-rpc.1.001118A98B3937.4.LEVEL"/*Rollo_BUE:4.LEVEL*/, 100); } if (getState("hm-rpc.1.001118A98B3868.0.UNREACH").val == true) { setState("hm-rpc.1.001118A98B3868.4.LEVEL"/*Rollo_HWR:4.LEVEL*/, 100); } }, 60000); } }); // Erzeuge Zustand Hitze_West-NordWest createState("javascript.0.Hitze_W-NW", function () { schedule("40 17 * * *", function () { if (getState("yr.0.forecast.day0.temperature_actual").val >= 21 && (getState("yr.0.forecast.day0.text").val == 'Schönwetter' || getState("yr.0.forecast.day0.text").val == 'Klarer Himmel') || getState("yr.0.forecast.day0.temperature_actual").val >= 25 && (getState("yr.0.forecast.day0.text").val != 'Regenschauer' || getState("yr.0.forecast.day0.text").val != 'Gewitter')) { setState("javascript.0.Hitze_W-NW"/*javascript.0.Hitze_W-NW*/, true); } else { setState("javascript.0.Hitze_W-NW"/*javascript.0.Hitze_W-NW*/, false); } }); }); // WC, Kinderzimmer & Schlafzimmer schedule("45 17 * * *", function () { if (getState("javascript.0.Hitze_W-NW").val == true) { setState("hm-rpc.1.001118A98B35E3.4.LEVEL"/*Rollo_KZ:4.LEVEL*/, 25); setState("hm-rpc.1.001118A98B38B1.4.LEVEL"/*Rollo_SZ:4.LEVEL*/, 25); setState("hm-rpc.1.001118A98B37E3.4.LEVEL"/*Rollo_WC:4.LEVEL*/, 25); timeout7 = setTimeout(function () { if (getState("hm-rpc.1.001118A98B35E3.0.UNREACH").val == true) { setState("hm-rpc.1.001118A98B35E3.4.LEVEL"/*Rollo_KZ:4.LEVEL*/, 25); } if (getState("hm-rpc.1.001118A98B38B1.0.UNREACH").val == true) { setState("hm-rpc.1.001118A98B38B1.4.LEVEL"/*Rollo_SZ:4.LEVEL*/, 25); } if (getState("hm-rpc.1.001118A98B37E3.0.UNREACH").val == true) { setState("hm-rpc.1.001118A98B37E3.4.LEVEL"/*Rollo_WC:4.LEVEL*/, 25); } }, 60000); } });