Combine payloads objects to one string

Skærmbillede 2022-07-14 kl. 14.42.25

My project is to control the color of a bulb with a color picker node. The payload is on the picture. I need to alter the payload to use in a call service node like this

{"rgb_color":[msg.payload.r,msg.payload.g,msg.payload.b]}

But I can't get the syntax right!

If you were to use an inject to set colour, what would you enter?

In other words, show us what you wish this value be converted to.

"rgb_color":[60,195,155]

Show us the full code and the error.

I suspect the node is wanting an object like {"rgb_color":[60,195,155]} not a string

In a function node...

msg.payload = { 
    rbg_color: [
        msg.payload.r, 
        msg.payload.g, 
        msg.payload.b
    ] 
}
return msg;

Thank you! That solved my problem! After correcting to rgb_color

Isn't that the same as you showed in your first post?

I see that now, but for some reason only Steve-Mcl's solution worked

You must have had a typo in the line.

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