Add up numbers in a message

Hey I'm a node-red noob, I need to add up the numbers in blue but I'm not sure how.
It's probable pretty simple.

you can use javascipt in a function node, or JSONata in a change node.
e.g.

[{"id":"19ebc061.cadb78","type":"inject","z":"bf9e1e33.030598","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"a\":1,\"b\":2,\"c\":3}","payloadType":"json","x":260,"y":220,"wires":[["594f31a5.0be01","62d55a1a.81300c"]]},{"id":"594f31a5.0be01","type":"change","z":"bf9e1e33.030598","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$sum($$.payload.*)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":490,"y":200,"wires":[["2855db0a.fae91c"]]},{"id":"62d55a1a.81300c","type":"function","z":"bf9e1e33.030598","name":"","func":"let values = Object.values(msg.payload);\nmsg.payload = values.reduce((a,v) => a+v);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":490,"y":280,"wires":[["2855db0a.fae91c"]]},{"id":"2855db0a.fae91c","type":"debug","z":"bf9e1e33.030598","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":740,"y":260,"wires":[]}]

I have found a noob way to add them up in the meantime, but thanks for the help!

solution
solution 1

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