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); });
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login
