@paul53
naja dann mach ich das doch über die enum.functions
Danke Paul!
Hallo zusammen
Ich habe für meinen Wohnzimmerstoren ein Skrypt (in Blockly) gemacht. Grundsätzlich funktioniert es, doch teilweise erhalte ich alle 15min eine Meldung das der Storen auf 100% geöffnet wurde und dann wieder auf 30%... dies wollte ich eigentlich mit der Variabel Auto_ausgelöst verhindern..
Seht ihr bei meinem Skript fehler / Optimierungsmöglichkeiten
Danke und Gruss

als code:
var timeout5, timeout3, timeout, timeout2, timeout6, Auto_ausgel_C3_B6st, timeout4;
/**
* Beschreibe diese Funktion …
*/
function Beschattungsprozess() {
setState("shelly.0.SHSW-25#BA6DC5#1.Shutter.Position"/*Position*/, 29);
timeout5 = setTimeout(function () {
setState("shelly.0.SHSW-25#BA6DC5#1.Shutter.Position"/*Position*/, 30);
console.log((['Der linker Storen ist zu: ',getState("shelly.0.SHSW-25#BA6DC5#1.Shutter.Position").val,'geöffnet'].join('')));
Telegrammeldung();
timeout4 = setTimeout(function () {
Auto_ausgel_C3_B6st = 1;
(function () {if (timeout4) {clearTimeout(timeout4); timeout4 = null;}})();
}, 1800000);
(function () {if (timeout5) {clearTimeout(timeout5); timeout5 = null;}})();
}, 60000);
}
/**
* Beschreibe diese Funktion …
*/
function Telegrammeldung() {
// Mitteilung an Telegram
timeout3 = setTimeout(function () {
sendTo("telegram", "send", {
text: (['Der linke Storen ist zu: ',getState("shelly.0.SHSW-25#BA6DC5#1.Shutter.Position").val,'% geöffnet!'].join(''))
});
(function () {if (timeout3) {clearTimeout(timeout3); timeout3 = null;}})();
}, 40000);
}
/**
* Beschreibe diese Funktion …
*/
function Aufmachen_voll() {
setState("shelly.0.SHSW-25#BA6DC5#1.Shutter.Position"/*Position*/, 100);
console.log((['Der linker Storen ist zu: ',getState("shelly.0.SHSW-25#BA6DC5#1.Shutter.Position").val,'geöffnet!'].join('')));
Telegrammeldung();
timeout6 = setTimeout(function () {
Auto_ausgel_C3_B6st = 0;
(function () {if (timeout6) {clearTimeout(timeout6); timeout6 = null;}})();
}, 600000);
}
// Manuelle Steuerung
on({id: "EigeneDatenpunkte.0.Storensteuerung"/*Storensteuerung*/, change: "ne"}, function (obj) {
var value = obj.state.val;
var oldValue = obj.oldState.val;
if ((obj.state ? obj.state.val : "") != getState("shelly.0.SHSW-25#BA6DC5#1.Shutter.Position").val) {
setStateDelayed("shelly.0.SHSW-25#BA6DC5#1.Shutter.Position"/*Position*/, (obj.state ? obj.state.val : ""), 2000, false);
Telegrammeldung();
}
});
// Automatische Steuerung bei Sonnenlicht
on({id: "deconz.0.Sensors.25.lux"/*LightLevel 25 lux*/, change: "ne"}, function (obj) {
var value = obj.state.val;
var oldValue = obj.oldState.val;
if ((obj.state ? obj.state.val : "") > 60000 && getState("shelly.0.SHSW-25#BA6DC5#1.Shutter.Position").val >= 100 && compareTime("13:30", "18:00", "between") && getState("deconz.0.Sensors.10.temperature").val > 18 && getState("deconz.0.Sensors.13.temperature").val > 23) {
timeout = setTimeout(function () {
if ((obj.state ? obj.state.val : "") > 55000 && getState("shelly.0.SHSW-25#BA6DC5#1.Shutter.Position").val >= 100 && getState("deconz.0.Sensors.13.temperature").val > 23) {
Beschattungsprozess();
(function () {if (timeout) {clearTimeout(timeout); timeout = null;}})();
} else {
(function () {if (timeout) {clearTimeout(timeout); timeout = null;}})();
}
}, 300000);
}
});
// Automatische Steuerung auf
on({id: "deconz.0.Sensors.25.lux"/*LightLevel 25 lux*/, change: "ne"}, function (obj) {
var value = obj.state.val;
var oldValue = obj.oldState.val;
if (Auto_ausgel_C3_B6st == 1 && (obj.state ? obj.state.val : "") < 45000 && getState("shelly.0.SHSW-25#BA6DC5#1.Shutter.Position").val != 100) {
timeout2 = setTimeout(function () {
if ((obj.state ? obj.state.val : "") < 45000 && getState("shelly.0.SHSW-25#BA6DC5#1.Shutter.Position").val != 100 || compareTime("18:31", "null", ">=")) {
Aufmachen_voll();
(function () {if (timeout2) {clearTimeout(timeout2); timeout2 = null;}})();
} else {
(function () {if (timeout2) {clearTimeout(timeout2); timeout2 = null;}})();
}
}, 1200000);
}
});