@JinnBln sagte:
Ich möchte einfach eine Funktion ausführen, die noch x mal erneut sendet.
Ich sende mit 1 s und 5 s Verzögerung nochmal, falls nicht der Aktor mit Ack triggert (dann werden die Timer gestoppt).
const actid = '...';
const ventid = '...';
var vent = getState(ventid).val; // Sollzustand
var act = getState(actid).val; // Aktor
var timer1 = null;
var timer5 = null;
function actor() {
if(act === vent) {
if(timer1) clearTimeout(timer1);
if(timer5) clearTimeout(timer5);
} else {
setState(actid, vent);
timer1 = setTimeout(function() {setState(actid, vent);}, 1000);
timer5 = setTimeout(function() {setState(actid, vent);}, 5000);
}
}
actor(); // script start
on(ventid, function(dp) {
vent = dp.state.val;
actor();
});
on({id: actid, ack: true}, function(dp) {
act = dp.state.val;
actor();
});