Rule to sendcommand an item state

hi,i want to make a rule so i can read an item state,a plain number, and send it as a command to another item.This will help me to find my house’s rooms for my roborock when i change the map…So i have created a number item “find_rooms” and my code that does not work is this :

rule "find_rooms"
when
    Item find_rooms changed
then
    var room = find_rooms.state as Number
	var set = "app_segment_clean[room]"
	MiRobotVacuumV2_Actions_ExecuteCommand.sendCommand(set)
end

any help to the right direction?

I am really not sure what you intend to do but at least I wonder what app_segment_clean[??] is? It is nowhere defined in the rule :thinking:
What do the logs say?

room is not a variable, but a string. It is not replaced by the value you assigned in line 1.
it needs to be something like:

var set = "app_segment_clean[" + room.toString() + "]"

Not sure if the syntax is correct.

that s it ,thnx mate