@paul53
So sollte es korrekt sein!!!
var schwimmer, restzeit, timeout, Intervall;
/**
* Beschreibe diese Funktion …
*/
function Vliesmotor() {
if (schwimmer) {
if (!Intervall && restzeit > 0) {
setState("sonoff.0.Aqua_Control.POWER2"/*Vliesmotor*/, true);
Intervall = setInterval(function () {
if (restzeit > 0 && schwimmer) {
restzeit = (typeof restzeit == 'number' ? restzeit : 0) + -1;
} else {
setState("sonoff.0.Aqua_Control.POWER2"/*Vliesmotor*/, false);
(function () {if (Intervall) {clearInterval(Intervall); Intervall = null;}})();
}
}, 2000);
}
} else if (getState("sonoff.0.Aqua_Control.POWER2").val) {
setState("sonoff.0.Aqua_Control.POWER2"/*Vliesmotor*/, false);
}
}
schwimmer = getState("sonoff.0.Aqua_Float.POWER3").val;
restzeit = 25;
on({id: 'sonoff.0.Aqua_Float.POWER3', change: "ne"}, function (obj) {
var value = obj.state.val;
var oldValue = obj.oldState.val;
(function () {if (timeout) {clearTimeout(timeout); timeout = null;}})();
timeout = setTimeout(function () {
schwimmer = (obj.state ? obj.state.val : "");
Vliesmotor();
}, 2000);
});
schedule("0 0 * * *", function () {
restzeit = 25;
Vliesmotor();
});
Vliesmotor();