Hi there, I just migrated from 2.5 to 3.0, and the following rule is thorwing up an error that I don’t understand:
rule "Get Kid's attention"
when
Member of Kids_Attention changed to "ON"
then
//set triggeringItem variables & get human-friendly names
val device = triggeringItem
logInfo(logName,device.name + " identified")
var charindex1 = device.name.lastIndexOf("_")
var itemID = device.name.substring(0,charindex1)
logInfo(logName,"itemID = " + itemID)
val color_current = gLamps.members.findFirst[ s | s.name == itemID+"_Color" ]
val alert = gLamps.members.findFirst[ s | s.name == itemID+"_Alert" ]
val color_persist = gLamps.members.findFirst[ s | s.name == itemID+"_Color_Persist" ]
logInfo(logName,"sending " + color_current.state + " to " + color_persist.name)
color_persist.sendCommand(color_current.state)
color_current.sendCommand(Kids_Alert_Color.state)
alert.sendCommand("LSELECT")
Thread::sleep(1000) // sleep half a second
while(alert.state == "LSELECT"){
Thread::sleep(500) // sleep half a second
}
triggeringItem.sendCommand(OFF)
logInfo(logName,"restoring " + color_persist.state + " to " + color_current.name)
color_current.sendCommand(color_persist.state)
end
And the error (and the lines leading up to it) is:
2020-12-31 00:49:54.536 [INFO ] [enhab.core.model.script.Lights Rules] - UnicornLamp_Attention identified
2020-12-31 00:49:54.537 [INFO ] [enhab.core.model.script.Lights Rules] - itemID = UnicornLamp
2020-12-31 00:49:54.539 [INFO ] [enhab.core.model.script.Lights Rules] - sending 253,76,11 to UnicornLamp_Color_Persist
2020-12-31 00:49:54.540 [ERROR] [internal.handler.ScriptActionHandler] - Script execution of rule with UID ‘lights-3’ failed: An error occurred during the script execution: Could not invoke method: org.openhab.core.model.script.actions.BusEvent.sendCommand(org.openhab.core.items.Item,java.lang.String) on instance: null in lights
Any thoughts?