I wrote a simple counter,
[{"id":"ee88e75c.aa2b98","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"152e6284.dd693d","type":"inject","z":"ee88e75c.aa2b98","name":"","topic":"","payload":"","payloadType":"date","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":200,"wires":[[]]},{"id":"2cad8f34.84dce","type":"debug","z":"ee88e75c.aa2b98","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":790,"y":200,"wires":[]},{"id":"5c999071.f713f","type":"counter","z":"ee88e75c.aa2b98","name":"","init":"0","step":"1","lower":"","upper":"","mode":"increment","outputs":1,"x":580,"y":200,"wires":[["2cad8f34.84dce","847329c2.4298c8"]]},{"id":"847329c2.4298c8","type":"ui_text","z":"ee88e75c.aa2b98","group":"7a3f46eb.b30dc8","order":20,"width":0,"height":0,"name":"","label":"count=","format":"{{msg.count}}","layout":"row-left","x":800,"y":260,"wires":[]},{"id":"fa8c110d.da02e","type":"ui_button","z":"ee88e75c.aa2b98","name":"","group":"7a3f46eb.b30dc8","order":20,"width":0,"height":0,"passthru":true,"label":"button","tooltip":"","color":"","bgcolor":"","icon":"","payload":"count= 0;","payloadType":"str","topic":"","x":390,"y":200,"wires":[["5c999071.f713f"]]},{"id":"5114837f.ea1a1c","type":"switch","z":"ee88e75c.aa2b98","name":"Switch","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"5000","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":150,"y":320,"wires":[["e174855f.3300a8","7af0bd47.ec6bb4"],[]]},{"id":"f1b9cfcd.3a17b","type":"delay","z":"ee88e75c.aa2b98","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":430,"y":540,"wires":[["e510ec8b.96cfb"]]},{"id":"e510ec8b.96cfb","type":"function","z":"ee88e75c.aa2b98","name":"increment value","func":"var value;\nvalue = parseInt(msg.payload);\nvalue = value + 1;\nmsg.payload = value;\nreturn msg;","outputs":1,"noerr":0,"x":670,"y":540,"wires":[["e034b8ef.463e08","aeca2078.e5242","4d7bbfae.23c69"]]},{"id":"72b726cc.c96898","type":"inject","z":"ee88e75c.aa2b98","name":"Demo","topic":"","payload":"0","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":270,"y":470,"wires":[["e174855f.3300a8","a6723e45.430e6"]]},{"id":"e034b8ef.463e08","type":"delay","z":"ee88e75c.aa2b98","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":440,"y":630,"wires":[["f1b9cfcd.3a17b"]]},{"id":"aeca2078.e5242","type":"debug","z":"ee88e75c.aa2b98","name":"","active":true,"console":"false","complete":"false","x":680,"y":630,"wires":[]},{"id":"e174855f.3300a8","type":"function","z":"ee88e75c.aa2b98","name":"reset other nodes","func":"msg.reset = true;\nreturn msg;","outputs":1,"noerr":0,"x":230,"y":540,"wires":[["f1b9cfcd.3a17b","e034b8ef.463e08"]]},{"id":"a6723e45.430e6","type":"delay","z":"ee88e75c.aa2b98","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":430,"y":470,"wires":[["e510ec8b.96cfb"]]},{"id":"7af0bd47.ec6bb4","type":"function","z":"ee88e75c.aa2b98","name":"set payload","func":"msg.payload = 0;\nreturn msg;","outputs":1,"noerr":0,"x":250,"y":430,"wires":[["a6723e45.430e6"]]},{"id":"3b31125b.1173ee","type":"ui_button","z":"ee88e75c.aa2b98","name":"","group":"7a3f46eb.b30dc8","order":21,"width":0,"height":0,"passthru":false,"label":"button","tooltip":"","color":"","bgcolor":"","icon":"","payload":"value=0","payloadType":"str","topic":"","x":440,"y":360,"wires":[["e510ec8b.96cfb"]]},{"id":"4d7bbfae.23c69","type":"ui_text","z":"ee88e75c.aa2b98","group":"7a3f46eb.b30dc8","order":22,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload}}","layout":"col-center","x":690,"y":440,"wires":[]},{"id":"7a3f46eb.b30dc8","type":"ui_group","z":"","name":"Sensors","tab":"83c97623.2a6ff8","disp":true,"width":"12","collapse":false},{"id":"83c97623.2a6ff8","type":"ui_tab","z":"","name":"Sensors","icon":"dashboard","disabled":false,"hidden":false}]
I want to reset the count to 0 whenever I press the button.
I also need it to start automatically and start counting again from 0.
But instead every click set the counter 1 step higher. If I double click it the count will go up by 2.