Demo rules cause error messages upon startup

The demo.rules file contains three rules that trigger upon startup. They simply initialize all members of Lights, Heating, and Windows with random values. Upon execution, all three rules produce errors:

2016-04-22 13:44:59.090 [ERROR] [m.r.internal.engine.RuleEngine] - Error during the execution of startup rule 'Initialize light states': Could not invoke method: org.openhab.model.script.actions.BusEvent.postUpdate(org.openhab.core.items.Item,java.lang.Number) on instance: null
2016-04-22 13:44:59.219 [ERROR] [m.r.internal.engine.RuleEngine] - Error during the execution of startup rule 'Initialize heating states': Could not invoke method: org.openhab.model.script.actions.BusEvent.postUpdate(org.openhab.core.items.Item,java.lang.Number) on instance: null
2016-04-22 13:44:59.335 [ERROR] [m.r.internal.engine.RuleEngine] - Error during the execution of startup rule 'Initialize contact states': Could not invoke method: org.openhab.model.script.actions.BusEvent.postUpdate(org.openhab.core.items.Item,java.lang.Number) on instance: null

The complaint is that the instances are null. Why would this happen???

Is it because the Items have not yet been instantiated when the rules execute?

BTW, for reference purposes, here’s one of the rules:

rule "Initialize light states"
when
System started
then
Lights?.members.forEach(light|
postUpdate(light, if(Math::random > 0.7) ON else OFF)
)
end

There was a recent change in 1.8.2 that has made the postUpdate action no longer work as reliably as the postUpdate method. Try changing those lines to:

light.postUpdate(if(Math::random > 0.7) ON else OFF)
2 Likes

Thank you!

I changed the postUpdate actions to methods and it eliminated the error messages.

Is there a move to deprecate the postUpdate action in favour of using a method or is this just a bug in 1.8.2?

The 1.8.2 demo now runs smoothly except for one error message produced by RRD4. It doesn’t appear to affect anything but perhaps you know how to get rid of it. Upon startup, this error is displayed in the console:
2016-04-22 19:07:59.172 [INFO ] [.p.rrd4j.internal.RRD4jService] - Removing invalid defintion component = null heartbeat = 0 min/max = 0.0/0.0 step = 0 0 archives(s) = [] 0 items(s) = []
What can be done, if anything, to fix this one?

I think it is just a bug. There are contexts where using the action makes more sense. You can usually make the action happy if you only pass it Strings.

Don’t know. Its an INFO level message so it should not be causing any problems. I’d ignore it.

Thanks! Solved the error for me too.