Help with mqtt color incoming tranformation

trying to extract the color value from a nspanel color widget .At mqttexplorer i get


from my tele/nspanel/RESULT topic
so i made a color channel and trying to extract the color value in the form of R,G,B .My Incoming Value Transformations is


but its not working…I am a complete noobie at tranformations so just need a hint where to fix that…
For Outgoing Value Format i use


and it is working very nice.

edit: i tried JS tranformation ,i add this nscolor.js file inside tranform folder

(function(i) {
    var rgb = JSON.parse(i)

    return rgb.colorR+","+rgb.colorG+","+rgb.colorB

and at channel’s Incoming Value Transformations :


with that i get in the logs

2023-03-09 09:59:45.906 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command 'undefined,undefined,undefined' from channel 'mqtt:topic:b94727f5:nspanel:nscolor' not supported by type 'ColorValue': For input string: "undefined"

Any ideas?

The transformation chaining with the symbol means take the result of the previous transformation as the input for the next transformation. So naturally your transformation above doesn’t work the way you intended.

Avoid using js transformation, because that’s going away in Openhab4. In its place, you can use SCRIPT transformation, which is available on openhab 3.4.2 (possibly one or two sub versions earlier too). SCRIPT transformation in turns lets you use JSScripting to perform the transformation.

Another way I can think of is to do this in a rule.

  • Have an item called String ResultItem that’s linked to receive the whole json data.
  • Have a rule that runs whenever this Item changed
  • Parse the value in the rule and update the intended Color item from the rule.

Someone else might come up with a better idea.

1 Like

I have never used this, but I wonder if JINJA transformation could work for you.

This is highly untested, just based on reading the above documentation, but try this transformation:


Either that or


I’m not familiar with the syntax, so a bit of trial and error or reading the fine manual is needed.


Colon added.


There is nothing wrong with your REGEX:(.*"id":"3".*)∩JS:nscolor.js Transformation

Try Logging you result from transformation first you can do the exact same to a string item to see the command you are giving your item.

Commanding colour value item is “interger,interger,interger” tells me it is something in your return line that is not formatted the way openHAB needs.


Your error "not supported by type 'ColorValue"


(function(i) {
    var rgb = JSON.parse(i)

    return rgb.NSPanel.params.colorR+","+rgb.NSPanel.params.colorG+","+rgb.NSPanel.params.colorB
1 Like




Also is your MQTT channel type set to RGB?

i put that in Incoming Value Transformations and i get

2023-03-09 14:05:33.540 [WARN ] [t.generic.ChannelStateTransformation] - Transformation service REGEX(S/.*RR" for pattern (.*?),.*rG":(.*?),.*rB":(.*?),.*/$1,$2,$3/g) not found!
2023-03-09 14:05:33.541 [WARN ] [ab.binding.mqtt.generic.ChannelState] - Command '{"NSPanel":{"ctype":"group","id":"3","params":{"switch":"on","light_type":1,"colorR":248,"colorG":168,"colorB":0,"bright":50,"mode":1}}}' from channel 'mqtt:topic:b94727f5:nspanel:nscolor' not supported by type 'ColorValue': {"NSPanel":{"ctype":"group","id":"3","params":{"switch":"on","light_type":1,"colorR":248,"colorG":168,"colorB":0,"bright":50,"mode":1}}} is not a valid string syntax


You need to write REGEX:( - you’re missing the colon symbol after REGEX

yes i saw that :slight_smile: but even i set


the linked color item does not update…no errors in the log .

that is working just fine mate thnx.

can i use the “same” script with SCRIPT transformation?