NEWS
Script Aktivzeit von HM Geräten
-
Hallo, ich hoffe ich bin hier richtig.
Ich suche nach einem Counter Script, das Zählt wenn ein HM Aktor oder Variable auf True ist und stehen bleibt wenn auf false ist, dann aber wieder weiter läuft wenn der Aktor wieder auf True geht.
Danke schonmal! :)
-
Vorschlag:
var idCount = 'javascript.0.Sekunden-Ein'; var timer = null; var cnt = getState(idCount).val; function count() { cnt++; setState(idCount, cnt); } // Scriptstart if(getState('hm-rpc.0.NEQ1234567.1.STATE').val) timer = setInterval(count,1000); on('hm-rpc.0.NEQ1234567.1.STATE', function(dp) { if(dp.state.val) timer = setInterval(count, 1000); else if(timer) clearInterval(timer); });Der Zähler-Datenpunkt muss vorher erstellt werden (im Admin-Reiter "Objekte").
-
was muss ich machen wenn der Datenpunkt bei ein "false" anstatt "true" liefert? `
if(getState('hm-rpc.0.NEQ1234567.1.STATE').val) timer = setInterval(count,1000); on('hm-rpc.0.NEQ1234567.1.STATE', function(dp) { if(dp.state.val) timer = setInterval(count, 1000); else if(timer) clearInterval(timer); });–>
if(!getState('hm-rpc.0.NEQ1234567.1.STATE').val) timer = setInterval(count,1000); on('hm-rpc.0.NEQ1234567.1.STATE', function(dp) { if(!dp.state.val) timer = setInterval(count, 1000); else if(timer) clearInterval(timer); });
