If you want to use variables inside a rule, the syntax is
val Number GasCount = 0.0
… where GasCount is a temp variable of a Number type (not an item)
Anyway, if I understand correctly your would like to reset the value of item GasCount (defined in an .items file) to 0.0 when the systems starts up and at midnight? If so you could try the following rules.
rule "System restart"
when
System started
then
// initialize your item GasCound here
GasCount.postUpdate(0.0)
end
// ***************************************
rule "Gas System Reset"
when
// at 00:00 every day
Time cron "0 0 0 1/1 * ? *"
then
// reset your item GasCound here
GasCount.postUpdate(0.0)
// Create a log entry in openhab.log to keep track
logInfo("Rule - Gas System Reset","GasCount set to 0.0")
end
GasCount is the calculated value - the variable.
GasCounter is the label to which I give it the value of GasCount.
I do not mind so much that GasCounter is null at first.
But I mind that I cannot pre-define GasCount.
Either way - your explanation helped a lot.
Thanks!
var Number GasCount = 0.0
rule "Gas System Calc"
when
Item ReedSwitch1 changed from 1 to 0
then
GasCount = GasCount + 0.1
GasCounter.postUpdate(GasCount)
end
rule "System restart"
when
System started
then
GasCount = 0.0
// initialize your item GasCound here
GasCounter.postUpdate(GasCount)
end
// ***************************************
rule "Gas System Reset"
when
// at 00:00 every day
Time cron "0 0 0 1/1 * ? *"
then
GasCount = 0.0
// reset your item GasCound here
GasCounter.postUpdate(GasCount)
// Create a log entry in openhab.log to keep track
logInfo("Rule - Gas System Reset","GasCount set to 0.0")
end