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