Thanks guys, but i just solved it already. Instead of using a function node, I created this flow. Serves the same purpose.
Feel free to ask if you wanna know more.
[{"id":"57244012.e6aee","type":"tab","label":"Flow 5","disabled":false,"info":""},{"id":"13d3c059.a4c13","type":"gate","z":"57244012.e6aee","name":"gate","controlTopic":"control","defaultState":"closed","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":244.01733016967773,"y":197.34387397766113,"wires":[["f3061e4a.a1dc2"]]},{"id":"d562c744.2b3838","type":"inject","z":"57244012.e6aee","name":"input","topic":"","payload":"1","payloadType":"num","repeat":"1","crontab":"","once":false,"onceDelay":0.1,"x":102.01742172241211,"y":198.34386706352234,"wires":[["13d3c059.a4c13"]]},{"id":"5d30a737.a655d8","type":"inject","z":"57244012.e6aee","name":"Start","topic":"control","payload":"open","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":98.0173511505127,"y":238.3437786102295,"wires":[["13d3c059.a4c13","fed1a4b1.a71798"]]},{"id":"162bad3d.dce733","type":"inject","z":"57244012.e6aee","name":"Stop","topic":"control","payload":"close","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":101.01739501953125,"y":277.3438415527344,"wires":[["13d3c059.a4c13","b25c02a3.1a24"]]},{"id":"e9f8d050.f1b6f","type":"debug","z":"57244012.e6aee","name":"Current Payload","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":560.0173263549805,"y":100.3438868522644,"wires":[]},{"id":"f3061e4a.a1dc2","type":"counter","z":"57244012.e6aee","name":"","init":"0","step":"1","lower":"","upper":"","mode":"increment","outputs":2,"x":395.01721572875977,"y":198.01061248779297,"wires":[["c59c6f83.80961","3b2aff24.cbc9d"],[]]},{"id":"8f64e5f2.d0b918","type":"function","z":"57244012.e6aee","name":"Reset Counter","func":"msg.reset=msg.payload\nreturn msg;","outputs":1,"noerr":0,"x":300.00709533691406,"y":284.64606380462646,"wires":[["f3061e4a.a1dc2"]]},{"id":"4df0a2f5.90388c","type":"inject","z":"57244012.e6aee","name":"Reset","topic":"","payload":"0","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":98.5833568572998,"y":316.0834059715271,"wires":[["8f64e5f2.d0b918"]]},{"id":"fed1a4b1.a71798","type":"function","z":"57244012.e6aee","name":"Start","func":"msg.payload=\"close\"\nmsg.topic=\"control\"\nreturn msg;","outputs":1,"noerr":0,"x":266.46529388427734,"y":323.36769104003906,"wires":[["2c1d6ac1.f5b806"]]},{"id":"b25c02a3.1a24","type":"function","z":"57244012.e6aee","name":"STOP","func":"msg.payload=\"open\"\nmsg.topic=\"control\"\nreturn msg;","outputs":1,"noerr":0,"x":262.4652290344238,"y":360.3676452636719,"wires":[["2c1d6ac1.f5b806"]]},{"id":"2c1d6ac1.f5b806","type":"gate","z":"57244012.e6aee","name":"gate","controlTopic":"control","defaultState":"open","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","defaultCmd":"default","persist":false,"x":629.0173416137695,"y":320.12154960632324,"wires":[["4d077d69.45e204"]]},{"id":"c59c6f83.80961","type":"trigger","z":"57244012.e6aee","op1":"","op2":"","op1type":"pay","op2type":"nul","duration":"-1","extend":false,"units":"s","reset":"","bytopic":"all","name":"","x":515.0173492431641,"y":260.12152671813965,"wires":[["2c1d6ac1.f5b806"]]},{"id":"4d077d69.45e204","type":"counter","z":"57244012.e6aee","name":"","init":"0","step":"1","lower":"","upper":"","mode":"increment","outputs":2,"x":723.0172348022461,"y":262.1215181350708,"wires":[["9b5929b.a338dd8"],["def262ef.f2b4"]]},{"id":"9b5929b.a338dd8","type":"debug","z":"57244012.e6aee","name":"To Proof the current payload is sent every second after STOP/RESET","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":992.0172805786133,"y":110.1215991973877,"wires":[]},{"id":"3b2aff24.cbc9d","type":"function","z":"57244012.e6aee","name":"[s] to [hh:mm:ss]","func":"// Message from preceeding node is in seconds - should be less than 24 hours (86400 seconds).\nvar time = (new Date(msg.payload * 1000)).toUTCString().match(/(\\d\\d:\\d\\d:\\d\\d)/)[0];\n// Pass on the string to the next node, what ever that may be. (groov Data Store for example).\nmsg.payload = time;\nreturn msg;","outputs":1,"noerr":0,"x":573.0173110961914,"y":195.12156295776367,"wires":[["e9f8d050.f1b6f","a97cb65e.07def8"]]},{"id":"def262ef.f2b4","type":"function","z":"57244012.e6aee","name":"[s] to [hh:mm:ss]","func":"// Message from preceeding node is in seconds - should be less than 24 hours (86400 seconds).\nvar time = (new Date(msg.payload * 1000)).toUTCString().match(/(\\d\\d:\\d\\d:\\d\\d)/)[0];\n// Pass on the string to the next node, what ever that may be. (groov Data Store for example).\nmsg.payload = time;\nreturn msg;","outputs":1,"noerr":0,"x":882.0172805786133,"y":337.1215419769287,"wires":[["a97cb65e.07def8"]]},{"id":"a97cb65e.07def8","type":"debug","z":"57244012.e6aee","name":"MACHINE RUNNING TIME","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":1000.0173530578613,"y":227.0104112625122,"wires":[]}]