Failure with generated Item name

Hello,

I am using the actual stable version of openhab (2.5.9). I get the following error:

Rule 'Volume Steuerung': An error occurred during the script execution: Could not invoke method: org.eclipse.smarthome.model.script.actions.BusEvent.sendCommand(java.lang.String,java.lang.String) on instance: null

in the logs when executing the following rule:

 rule "Volume Steuerung"
when
    Item MqttSonosBox_Volume changed 
then
//Sonos Gerät festlegen und Items benennen
var String sonosselect = FabiBox_SonosSelect.state.toString
var String sonos = transform("MAP", "FabiBox.map", sonosselect)
val sonoslautstaerke = ScriptServiceUtil.getItemRegistry.getItem(sonos + "_Lautstaerke") as DimmerItem
sendCommand(sonoslautstaerke, MqttSonosBox_Volume.state)
end

What is my failure. Can somebody please point me in the right direction?

Best Regards

Johannes

We need to see your Item definitions too.

hmm, so that sendCommand() action is looking for two strings …

Is sonoslautstaerke a string variable?
Don’t think so, isn’t that an Item object that you just selected with ScriptServiceUitil?
How about MqttSonosBox_Volume.state, is that a string?
Doubt it, unless it is from a String type Item.

As you’ve got the Item, you may as well use it’s own method, then you’ve only one argument to stringify.
sonoslautstaerke.sendCommand(MqttSonosBox_Volume.state.toString)

I suggest simplifying your rule. Remove the sonoslautstaerke variable and use…

sendCommand(sonos + "_Lautstaerke", MqttSonosBox_Volume.state.toString)

Super, the problem was the this part: MqttSonosBox_Volume.state.toString
I had to add the .toString.

Thank You!!!