Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.sendCommand(org.eclipse.smarthome.core.items.Item,java.lang.String) on instance: null

So I managed to update to snapshot and now I have a little quirk in one of my rules scripts. That’s the script part:

case "xxxxxx" : {                       //double button, hallway, left
            if (HallwayDim.state > 50) {
                if (sceneSwitch.state == 0) {
                        if (isNight.state == ON) sceneSwitch.sendCommand(2)
                        else sceneSwitch.sendCommand(4)
                } else if (sceneSwitch.state > 0) sceneSwitch.sendCommand(sceneSwitch.state)
                        else HallwayDim.sendCommand(0)
            }
            if (HallwayDim.state < 50) HallwayDim.sendCommand(100)
        }

When the HallwayDim is > 50 and a scene is set (sceneSwitch >0) I now get the mentioned error:

[ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule ‘rf received’: An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.sendCommand(org.eclipse.smarthome.core.items.Item,java.lang.String) on instance: null

Is there any way around that?

Add some logging to determine which sendCommand it is failing on.

In all likelihood, you will need some sort of cast of the state objects to Number. I’m going to guess the problem line is:

sceneSwitch.sendCommand(sceneSwitch.state as Number)
4 Likes

Thanks, jep, that was the one. I fixed it by introducing a variable now. I’ll try if the “as Number” also works :).

    val int currentScene = sceneSwitch.state
[...]
        case "xxxxxx" : {                       //double button, hallway, left
            if (HallwayDim.state > 50) {
                if (sceneSwitch.state == 0) {
                        if (isNight.state == ON) sceneSwitch.sendCommand(2)
                        else sceneSwitch.sendCommand(4)
                } else if (sceneSwitch.state > 0) sceneSwitch.sendCommand(currentScene)
                        else HallwayDim.sendCommand(0)
            }
            if (HallwayDim.state < 50) HallwayDim.sendCommand(100)
        }
1 Like