How can I add a msg.xxx variable into a change node?

[{"id":"9d4d90de.91179","type":"tab","label":"Flow 5","disabled":false,"info":""},{"id":"b3fe91.07c4e17","type":"server-state-changed","z":"9d4d90de.91179","name":"Brightness changed","server":"817e283a.e704f8","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_number.light_strip_brightness","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":320,"y":200,"wires":[["44c70077.bf323"]]},{"id":"7ff53dc4.9645a4","type":"change","z":"9d4d90de.91179","name":"22","rules":[{"t":"set","p":"topic","pt":"msg","to":"zwave/_CLIENTS/ZWAVE_GATEWAY-Mosquitto/api/sendCommand/set","tot":"str"},{"t":"set","p":"payload","pt":"msg","to":"{     \"args\": [     {       \"commandClass\": 112,       \"nodeId\": 12,       \"property\": 23     },     \"set\",     [       23,       {{brightness}},       4     ]   ] }","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":830,"y":200,"wires":[["9a70e8de.15d6c8"]]},{"id":"44c70077.bf323","type":"change","z":"9d4d90de.91179","name":"","rules":[{"t":"set","p":"brightness","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":600,"y":200,"wires":[["7ff53dc4.9645a4"]]},{"id":"9a70e8de.15d6c8","type":"debug","z":"9d4d90de.91179","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":990,"y":200,"wires":[]},{"id":"817e283a.e704f8","type":"server","name":"Home Assistant","addon":true}]

When I change brightness slider, the event state node is triggered and the number is put into msg.payload.

I use the change node to move the number value in msg.payload into msg.brightness

What I then want in the change node labeled 22 is to input that msg.brightness value here:

But when I try that and check the debug, it just sends {{brightness}} instead of the number value. So it will send this…
image

When I want it to send this (assuming brightness slider was set to 99)
image

This is the issue.
You’re sending string data. So node red reads it as string.

I don’t know if you can “mix” in a change node.
But you can do it in a function node.

This is one of my function nodes:

You write json code and can add messages as variables.

1 Like

@hellis81 that worked, thanks!

image