[solved] Item cast problem? Use string item to trigger Rollershutter item

I am using following item config within a group (my plan is to use in future more String and Rollershutter Items):

Group gName "group name" { .....

String test_stop "name1" (gName) {....
Rollershutter test "name2" (gName) {....

String test2_stop "name10" (gName) {....
Rollershutter test2 "name20" (gName) {....

My rule should be implemented like this, if a member of the string item receives STOP, the item name should be modified (remove “_stop”) to get the item name of the Rollershutter.
I am able to do the modification of the string via REGEX but openhab does not like to use this modified string in combination with sendCommand():

rule "test"
  Member of gName received command STOP
  val itemName = transform("REGEX","(.*)_stop",triggeringItem.name)  //remove _stop string

I assume I need something like a string cast to rollershutter?
Someone a good advice? :upside_down_face:

One of my error messages was like:

[ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'test': 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

You can’t just call methods on an Item Object when all you have is that Item’s name. See Design Pattern: Associated Items for three ways to do this. In this case the best is probably to just use the sendCommand Action.

It’s also way easier to just use String operations to strip off the “_stop”.

val itemName = triggerinItem.name.replace("_stop", "")
sendCommand(itemName, "STOP")