How to sum many messages (numbers) that's arrive from one node

Hello this is me Badr I'm student I tried many time to sum the messages that I arrive them from the same node
For example I'm sending the temperature value 25° after a while mints the temperature become 30 so I need to add the second value that I arrived it (30) to the first value which is (25) to become the output value (55). After this when I arrive different value for example 35 it will add to the last value 55 to be the output 55+20= (((75)))
so when I arrive message it will add to the last value that I got
please help me to do the function that sum the values is arriving to the gauge.
I will I appreciate your help.
Thanks,,

You would need to store the sumed value in context storage
e.g.

[{"id":"f9da93c6.58f8f","type":"inject","z":"c74669a0.6a34f8","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"20","payloadType":"num","x":120,"y":4020,"wires":[["1cd0b2ff.15800d"]]},{"id":"1cd0b2ff.15800d","type":"function","z":"c74669a0.6a34f8","name":"","func":"msg.payload = (flow.get(\"sumTempVal\") || 0) + msg.payload;\nflow.set(\"sumTempVal\", msg.payload);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":320,"y":4080,"wires":[["7db5426b.da77f4"]]},{"id":"7db5426b.da77f4","type":"debug","z":"c74669a0.6a34f8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":580,"y":4020,"wires":[]}]

Thank you so much it helps me. ^_^.

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