Sum up values from different text nodes

Hey guys,
I have 3 text nodes that have certain values written to them once a day. I now want to sum them up once a day and have them in another text node. I would also like to save the values until they are overwritten so they don't disappear after rebooting node red.

What would be the best way to do that? It seems like I cant use the values from the text nodes, so I guess I have to store them in some other node.

Best regards

I'm guessing all these are numbers.

Get the join node and set it to manual and set the count to 3.

Output it as either an object or array.

Send that into a function node and parse the message and add the three values.

If you need more help, I can offer some examples.

1 Like

Here's an example flow.

[{"id":"e956d25316d0cce4","type":"join","z":"65c9b63cb09879a0","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":2100,"y":150,"wires":[["0199930b2b36b3c9"]]},{"id":"ac2c39148fb1e8e1","type":"inject","z":"65c9b63cb09879a0","name":"Reading 1","props":[{"p":"payload"},{"p":"topic","v":"","vt":"num"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"18","payloadType":"num","x":1950,"y":100,"wires":[["e956d25316d0cce4"]]},{"id":"9dee30a5a66c31ff","type":"inject","z":"65c9b63cb09879a0","name":"Reading 2","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"3","payloadType":"num","x":1950,"y":150,"wires":[["e956d25316d0cce4"]]},{"id":"9582d0acc2a9fa28","type":"inject","z":"65c9b63cb09879a0","name":"Reading 3","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"22","payloadType":"num","x":1950,"y":200,"wires":[["e956d25316d0cce4"]]},{"id":"0199930b2b36b3c9","type":"function","z":"65c9b63cb09879a0","name":"","func":"let a = msg.payload[0];\nlet b = msg.payload[1];\nlet c = msg.payload[2];\n\nlet total = a + b + c;\n\nmsg.payload = total;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":2110,"y":190,"wires":[["9433cf93f867b403"]]},{"id":"9433cf93f867b403","type":"debug","z":"65c9b63cb09879a0","name":"Total","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":2250,"y":190,"wires":[]}]
2 Likes

That works perfectly, thank you. I was having problems because for every text node I get a stream of msg. Using a throttle node solved that problem and I can use your solution.

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