Ich erfasse die Betriebsstunden meiner Zirkulationspumpe aktuell so:
Item
Code: Alles auswählen
Number Zirkulationspumpe_BSZ "Betriebsstunden Zirkulationspumpe [%.1f h]"
Code: Alles auswählen
rule "Betriebsstunden bestimmen"
when
Item Zirkulationspumpe changed
then
if(previousState == NULL) {
logInfo("duration","Alter Wert war NULL, Abbruch!")
return;
}
if(Zirkulationspumpe.state == ON) {
nStart = now.toInstant().toEpochMilli()
logInfo("duration","Zirkulationspumpe wurde eingeschaltet. Startwert {}",nStart)
}
if(Zirkulationspumpe.state == OFF) {
var Number nDiff = now.toInstant().toEpochMilli() - nStart
logInfo("duration","Zirkulationspumpe wurde ausgeschaltet. Differenz {}",nDiff)
if (Zirkulationspumpe_BSZ.state==NULL)
Zirkulationspumpe_BSZ.postUpdate(nDiff/3600000)
else
Zirkulationspumpe_BSZ.postUpdate((Zirkulationspumpe_BSZ.state as Number) + nDiff/3600000)
}
end
Aber wie muss ich meine Rule anpassen?
Gruß Tom