import org.openhab.core.library.types.*import org.openhab.core.persistence.*import org.openhab.model.script.actions.*import org.joda.time.*
import org.joda.time.format.*
rule "Sum Daily Bruleur Time"when Item hearMazoutBruleurState_test changed then
if(hearMazoutBruleurState_test.state == ON ){
postUpdate(heatMazoutBruleurLastOnState, new DateTimeType()) logInfo("BRULEUR", "enclanchement du bruleur") }else{ var DateTime now = new DateTime() var DateTime LastOnState = heatMazoutBruleurLastOnState.state as DateTimeType logInfo("BRULEUR","LastOnState value " + LastOnState) //This returns the correct datetime
var Number execDuration = Seconds.secondsBetween(now, LastOnState).getSeconds() //logInfo("BRULEUR", "Le bruleur vient de fonctionner " + execDuration + "secs.) }
end
2015-02-04 10:50:20.011 [ERROR] [o.o.c.s.ScriptExecutionThread ] - Error during the execution of rule 'Sum Daily Bruleur Time': The name 'Seconds' cannot be resolved to an item or type.
Try the following syntax;var Number execDuration = Seconds::secondsBetween(now, LastOnState).getSeconds()
var DateTimeType LastOnState = heatMazoutBruleurLastOnState.state as DateTimeTypevar Number execDuration = Seconds::secondsBetween(now, new DateTime(LastOnState.calendar.timeInMillis)).getSeconds()
2015-02-04 12:03:54.399 [INFO ] [g.openhab.model.script.BRULEUR] - PrevOnState vaut 2015-02-04T12:03:47
2015-02-04 12:03:54.408 [INFO ] [g.openhab.model.script.BRULEUR] - Now vaut 2015-02-04T12:03:54.408+01:00
2015-02-04 12:03:54.444 [INFO ] [g.openhab.model.script.BRULEUR] - Le bruleur vient de fonctionner 6 secs.
import org.openhab.core.library.types.*import org.openhab.core.persistence.*import org.openhab.model.script.actions.*
import org.joda.time.*import org.joda.time.format.*
rule "Sum Daily Bruleur Time"when Item hearMazoutBruleurState_test changed then
if(hearMazoutBruleurState_test.state == ON ){ postUpdate(heatMazoutBruleurLastOnState, new DateTimeType()) }else{ var DateTimeType prevOnState = heatMazoutBruleurLastOnState.state as DateTimeType logInfo("BRULEUR","PrevOnState vaut " + prevOnState) logInfo("BRULEUR","Now vaut " + now) var Number execDuration = Seconds::secondsBetween(new DateTime(prevOnState.calendar.timeInMillis), now ).getSeconds() logInfo("BRULEUR","Le bruleur vient de fonctionner " + execDuration + " secs.") //Now I have just have to increment this amount of secs to have the total daily. } endCan you tell me why we use the :: (two semicolons) ?