Hi, not 100% certain if it is the sum total of payload values or count of payloads but here is a demo that should cater for both...
[{"id":"226f9f18a6afc487","type":"function","z":"a0a5ddea2fa4216f","name":"Payload Total","func":"\nlet payload_history = context.get(\"payload_history\") || [];//get remembered count\nlet statusMessage;\nlet sum = 0, count = 0;\n\nif (msg.topic === \"release\") {\n sum = payload_history.reduce((a, b) => a + b, 0) \n count = payload_history.length;\n payload_history = [];\n node.status(\"Sum: 0\");\n} else if(typeof msg.payload === \"number\") {\n payload_history.push(msg.payload);\n sum = payload_history.reduce((a, b) => a + b, 0) \n count = payload_history.length;\n node.status(\"Sum: \" + sum);\n}\n\ncontext.set(\"payload_history\", payload_history); //remember count\n\nif(msg.topic == \"release\") {\n msg.payload = {\n count: count,\n sum: sum\n }\n return [null, msg];\n} \n\nreturn [msg, null];\n\n","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":690,"y":660,"wires":[["5999900b2df185a4"],["e6140c609f34d805"]]},{"id":"5999900b2df185a4","type":"debug","z":"a0a5ddea2fa4216f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":850,"y":620,"wires":[]},{"id":"0f206903f17e01f9","type":"inject","z":"a0a5ddea2fa4216f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":510,"y":580,"wires":[["226f9f18a6afc487"]]},{"id":"08c8d12fc86a3f32","type":"inject","z":"a0a5ddea2fa4216f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"5","payloadType":"num","x":510,"y":620,"wires":[["226f9f18a6afc487"]]},{"id":"e6140c609f34d805","type":"debug","z":"a0a5ddea2fa4216f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","statusVal":"payload","statusType":"auto","x":850,"y":700,"wires":[]},{"id":"9a5781f4bb1f8711","type":"inject","z":"a0a5ddea2fa4216f","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"10","payloadType":"num","x":510,"y":660,"wires":[["226f9f18a6afc487"]]},{"id":"339f7d87c33b9917","type":"inject","z":"a0a5ddea2fa4216f","name":"Release (every 10m)","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"600","crontab":"","once":false,"onceDelay":0.1,"topic":"release","payload":"0","payloadType":"num","x":460,"y":720,"wires":[["226f9f18a6afc487"]]}]