Closed GoogleCodeExporter closed 8 years ago
I wouldn't like to bloat my rules with unnecessary variables to workaround this
bug. How are you (everyone else) avoiding this?
Here's another example:
var Number last_waterpulse_millisec = null
rule "Calculate water flow"
when Item WaterPulseCounter changed or
Time cron "2 0/2 * * * ?" then
val Number current_value = WaterPulseCounter.state as DecimalType
val Number current_millis = now.millis
println( "water flow 1" )
val State state = WaterPulseCounter.historicState( now.minusMinutes( 2 ) )
val Number old_value = if( state instanceof DecimalType ) state as DecimalType else WaterPulseCounter.state as DecimalType
println( "water flow 2" )
val Number current_flow_litres = ( old_value - current_value ) * WATERLITERS_PER_PULSE
println( "water flow 3" )
if ( last_waterpulse_millisec == null ) { // We do not know from when to measure
println( "water flow 3.1" )
postUpdate( WaterFlowSpeed, 0 )
}
else {
println( "water flow 4" )
val Number elapsed_time_minutes = ( current_millis - last_waterpulse_millisec ) / ( 60 * 1000 )
println( "water flow 5" )
val Number flowspeed = current_flow_litres / elapsed_time_minutes
println( "water flow 6" )
postUpdate( WaterFlowSpeed, flowspeed )
}
last_waterpulse_millisec = current_millis
end
This produces the following output:
water flow 1
water flow 2
water flow 3
10:36:03.190 ERROR o.o.m.r.i.e.ExecuteRuleJob[:77] - Error during the execution
of rule Calculate water flow
java.lang.NullPointerException: null
at org.openhab.model.script.lib.NumberExtensions.operator_equals(NumberExtensions.java:73)
Original comment by kristian...@gmail.com
on 22 May 2013 at 7:43
Original comment by kai.openhab
on 22 May 2013 at 8:30
For "Null check" I get the same output on my Systems(Linux VM, Windows 64)
openHab Version 1.3 demo.
Older Versions sometimes completely ignores Startup Rules at first Startup.
At a second Startup get always: 'Null check': null
> How are you (everyone else) avoiding this?
I use Timers to start more complex Rules later and have to do many test-loops
to avoid.
I notice these Issue, combined mostly with more complex rules, since openHab
Version 0.9.
Hope this helps to delimit the Problem a little bit.
Original comment by Helmut.L...@gmail.com
on 9 Jun 2013 at 5:02
Migrated to https://bugs.eclipse.org/bugs/show_bug.cgi?id=423536
Original comment by kai.openhab
on 8 Dec 2013 at 2:55
Original issue reported on code.google.com by
kristian...@gmail.com
on 14 May 2013 at 6:44