I want to count the amount of messages, store them and then send the total every 10 seconds to the mqtt broker.
Like the first signal on the broker is 0, then 50, then 100......
I got the following flow but it just send every 10 seconds a message of 1
[{"id":"64dc420.1dbabc","type":"debug","z":"45ce3f2c.e344e","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":910,"y":400,"wires":[]},{"id":"f2036a6d.357388","type":"trigger","z":"45ce3f2c.e344e","op1":"","op2":"","op1type":"pay","op2type":"pay","duration":"10","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":910,"y":340,"wires":[["a17e488c.2f29b8"]]},{"id":"a17e488c.2f29b8","type":"mqtt out","z":"45ce3f2c.e344e","name":"","topic":"pers77_slag","qos":"2","retain":"","broker":"d2d18b60.565bd8","x":1130,"y":340,"wires":[]},{"id":"95ce3366.3c73c","type":"function","z":"45ce3f2c.e344e","name":"count","func":"var count=context.get('count') || 1;\ncount +=1;\nmsg.payload = \"\"+msg.payload+\" \"+ count;\ncontext.set('count', count);\nreturn msg;","outputs":1,"noerr":0,"x":720,"y":340,"wires":[["f2036a6d.357388","64dc420.1dbabc"]]},{"id":"b290d349.2180d8","type":"counter","z":"45ce3f2c.e344e","name":"","init":"0","step":"1","lower":"","upper":"","mode":"increment","outputs":"2","x":460,"y":440,"wires":[["a370d054.b2849","712a82fb.8654dc","95ce3366.3c73c"],["638f49f0.d941e8"]]},{"id":"41121122.d792c","type":"switch","z":"45ce3f2c.e344e","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"str"},{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":290,"y":440,"wires":[["b290d349.2180d8"],[]]},{"id":"71ae4ba2.299c44","type":"rpi-gpio in","z":"45ce3f2c.e344e","name":"","pin":"35","intype":"down","debounce":"30","read":false,"x":120,"y":440,"wires":[["41121122.d792c"]]},{"id":"d2d18b60.565bd8","type":"mqtt-broker","z":"","name":"Mqtt_Broker","broker":"192.168.16.76","port":"1883","tls":"","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]