Insert value from payload
Whit parseInt
parseInt will take the first number in the payload and store it
var output = msg.payload.split(","); // split value whit ,
var R = parseInt(output[0]); // store value
var G = parseInt(output[1]);
var B = parseInt(output[2]);
msg.payload ={
"rgb": [R,G,B] //create a msg array whit stored value
};
return msg;
Result
Whitout parseInt
var output = msg.payload.split(",");
var R = output[0];
var G = output[1];
var B = output[2];
msg.payload ={
"rgb": [R,G,B]
};
return msg;