RGB format error

Hi Guys,

I've got this probably noob question. But I can't find how to get this format rigth.

I need an output of: rgb:255,255,255 where the values are variables.

This is my code now:

var red = flow.get("red");
var green = flow.get("green");
var blue = flow.get("blue");

msg.payload = {
    
    "selector": "label:Ledstrip",
    "power": "on",
    "color": {"rgb": [red,green,blue] },
    "duration": 5,
    "infrared": 1
}


return msg;

Which gives an output of:

color:
	rgb:
		0:255
		1:255
		2:000

How can I get this in one line comma-seperated?

Assuming you mean a string of rgb:255,255,255...

var red = flow.get("red");
var green = flow.get("green");
var blue = flow.get("blue");
var color = "rgb:" + [red,green,blue].join(",");

msg.payload = {
    
    "selector": "label:Ledstrip",
    "power": "on",
    "color": color,
    "duration": 5,
    "infrared": 1
}

Exactly! Thanks!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.