There is a whole lot going on here that is not obvious for a lot of users. And that’s one reason why the XY Problem is so pernicious.
For example, in this case RGB_Lamp_03_ColRGBWStr.stateis not a String. Its a StringType which is a type of State that can be carried by an Item. So the problem isn’t that it’s a variable, it that we don’t have a good idea of what type that variable is. You are assigning that StringType to a variable that is typed to be a String. I’m actually a little surprised that you don’t get errors in your logs when you assign the state to OldColor. But it does appear to work but I’m going to guess it converts the type of OldColor to StringType. The reason why that’s a problem is StringType is not a Command, it’s only a State. Consequently you cannot use it to send a command to an Item.
But you can send a String as a command because OH will parse and convert it to the right type for you.
Try making it so you actually save the String and not StringType to the variable.
Thanks Rich,
realy hard to understand what type is used when, specially StringType is …
But your solution works,
OT: saving from old power status (Type: Switch) was mutch easier and works directly … OldStatus=RGB_Lamp_03_Power.state … RGB_Lamp_03_Power.sendCommand(OldStatus)