Dynamic variable name in rules

Hy to everyone!

If my rule is triggered i want to split the string in Item scene_x and work with this string.
The x i get from the scene_selector.

rule "scene_select"
when
    Item scene_selector received command
then
    logInfo("Scene", 'scene_'+scene_selector.state.toString.split(';').get(0))
end

What do i have to write instead of this

 'scene_'+scene_selector.state.toString.split(';').get(0)

that i can work with the Value?

Thank you!

You cannot access an Item like this. You have to have the actual Item object. Like I posted in the other thread, see Design Pattern: Working with Groups in Rules for how to pull an Item Object out of a Group using its name.

Correct. I don’t think you can even do that in any language except Javascript’s eval()

The other ‘hackish’ solution I could think of is making a GET REST call to the OH API