Move data (not payload) from one node to another

HI all,

I am trying to take the rgb_color value from a light and take that value and set that as the value for the rgb_color in another node for a different node.

I just can't seem to move the value via any methods i know.

I am sure it is very simple, but i just cant get it.

Many thanks in advance for any help with this.

Have you tried a change node set to move?

There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.

1 Like

thank you, i was using change rather than set.

I can now get the array data, so effectivly payload[0] payload[1] and payload [3]

image

when i try both:

{
    "rgb_color": "{{payload[0],payload[1],payload[2]}}",
    "brightness": "35",
    "effect": "None"
}

and

{
    "rgb_color": "{{payload}}",
    "brightness": "35",
    "effect": "None"
}

I just cant seem to do anything with it.

Where are you putting that code and if you add a debug node showing what is coming out then what do you see?
[Edit] Also what do you want to see coming out?
[Further Edit] Guessing that you are putting that in a function node and that what you want is "rgb_color": "100,100,100" then you must use javascript, not moustache notation. So you want something like (untested)

rgb_color:  `"${payload[0]},${payload[1],${payload[2]}"`

See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

thats the data part of a home assistant call service node:


all i get is an error

"Call-service API error.  Error Message: None for dictionary value @ data['rgb_color']"

I believe that is the first time you have mentioned HA. I have no knowledge of HA.

sorry,

HA forums saying its a node red issue - as i can enter the value directly, just not transfer the value

sorry replied to wrong person

I think it need to be an array

Does the node config input allow mustache templete?

{
    "rgb_color": [{{payload}}],
    "brightness": "35",
    "effect": "None"
}

it does when
" DataJSON

I have checked it is passing a JSON array in payload

but that has not changed the error unfortunatly.

What home Assistant node are you using?

its the call service node part of node-red-contrib-home-assistant-websocket

Not much of a how to in the info of that node. I did not see any links to more documentation.
Try using the change node to create the msg, and use msg in the data input field.
e.g.

[{"id":"187967a.a95e618","type":"inject","z":"4484ee28.caa3c","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[255, 0 , 1]","payloadType":"json","x":150,"y":500,"wires":[["67f3f52c.e2114c"]]},{"id":"67f3f52c.e2114c","type":"change","z":"4484ee28.caa3c","name":"","rules":[{"t":"set","p":"hold","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"{\"brightness\":\"35\",\"effect\":\"None\"}","tot":"json"},{"t":"set","p":"payload.rgb_color","pt":"msg","to":"hold","tot":"msg"},{"t":"delete","p":"hold","pt":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":500,"wires":[["269a25ff.79887a"]]},{"id":"269a25ff.79887a","type":"debug","z":"4484ee28.caa3c","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":590,"y":360,"wires":[]}]

Rather than using moustache templates with JSON, you could use JSONata instead. In this case, after changing from "{}" to "J:", you would use:

{
    "rgb_color": payload,
    "brightness": "35",
    "effect": "None"
}

Brightness in HA is normally a number too - so no quotes. FWIW I prefer to use "brightness_pct".

thanks all, managed to get it working thank to all your advice :slight_smile: