If I downgrade to 2.5.1-2 ( sudo apt-get install openhab2=2.5.1-2 ) , it works fine again.
Here’s the error:
2020-02-21 20:38:00.207 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'Lock: Update lock states after alarm_raw event': cannot invoke method public abstract java.lang.String org.eclipse.smarthome.core.items.Item.getName() on null
I’m using a common config for Yale-type locks for mapping JSON data
rule "Lock: Update lock states after alarm_raw event"
when
Item Lock_SideGarage_Alarm_Raw changed
then
val actionItem = gLock.members.findFirst[ item | item.name.toString == triggeringItem.name.toString.replace("_Alarm_Raw","") ]
logInfo("Rules", "Lock: Alarm events: {}=[{}]",actionItem.name,triggeringItem.state.toString)
switch (transform("JSONPATH", "$.type", triggeringItem.state.toString)) {
case "0" : {
// do nothing
}
case "21" : {
actionItem.postUpdate(ON)
vGR_MA_Lock.postUpdate(ON)
logInfo("Rules", "Case 21 executed")
}
case "24" : {
actionItem.postUpdate(ON)
vGR_MA_Lock.postUpdate(ON)
logInfo("Rules", "Case 24 executed")
}
....
<snip>
I feel like the error is one of these three lines: val actionItem = gLock.members.findFirst[ item | item.name.toString == triggeringItem.name.toString.replace("_Alarm_Raw","") ] logInfo("Rules", "Lock: Alarm events: {}=[{}]",actionItem.name,triggeringItem.state.toString)
but I’m not sure what to do, since it works fine in 2.5.1-2 but only breaks when I upgrade to 2.5.2-1 and quite frankly I’m not sure how to debug that or where to even start.
Seems like quite a few people are using this rule, so I figured I would post this since others will likely run into the same issue.
First I would stop OH and clean the cache. Next try touching the rule file and any items that are associated with it and see if that makes a difference.
If your search of gLock members comes up empty handed, then actionItem will be null and the following logInfo(), which tries to get its name, will fail.
There are reports that Items can be missed or late creation at load time - the cache clean exercise may help here.