Hi All,
I'm trying to create a counter that counts the days from one position of the switch and a seperate count when the switch is in the other position, when i move the switch i would like the other counter to pause but i'm having no luck. At the moment I'm using a delay and a count node but when i switch the switch it keeps counting when i don't want it to. Is there a way to reset the delay node. I know it would be possible to do this in a function node but i don't know the correct syntax
[{"id":"5d94a949.60db88","type":"ui_switch","z":"2b6f7cd2.b0d1a4","name":"","label":"Light Cycle","tooltip":"","group":"51e31138.899ea","order":3,"width":4,"height":1,"passthru":true,"decouple":"false","topic":"","style":"","onvalue":"0","onvalueType":"num","onicon":"","oncolor":"","offvalue":"1","offvalueType":"num","officon":"","offcolor":"","x":1510,"y":1440,"wires":[["975f1b44.102758","e3e5addd.68dbe","987b42c2.886b7","2df10e3e.285a12","896e1781.a2504","1280becf.6f8129","d96f0ad6.d7c4e8"]]},{"id":"88aaf065.6cf8b","type":"delay","z":"2b6f7cd2.b0d1a4","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"days","rate":"1","nbRateUnits":"","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1980,"y":1220,"wires":[["ee2f325a.a76858"]]},{"id":"175bde4e.4fc502","type":"ui_text","z":"2b6f7cd2.b0d1a4","group":"1e7f45a3.99f78a","order":4,"width":3,"height":1,"name":"","label":"Days in Flower","format":"{{msg.payload}}","layout":"row-spread","x":2160,"y":1240,"wires":[]},{"id":"ee2f325a.a76858","type":"counter","z":"2b6f7cd2.b0d1a4","name":"","init":"0","step":"1","lower":"","upper":"","mode":"increment","outputs":2,"x":1980,"y":1260,"wires":[["88aaf065.6cf8b","175bde4e.4fc502","9d149af6.b4e36"],[]]},{"id":"896e1781.a2504","type":"switch","z":"2b6f7cd2.b0d1a4","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":1830,"y":1260,"wires":[["ee2f325a.a76858"]]},{"id":"4d2a7d60.34366c","type":"counter","z":"2b6f7cd2.b0d1a4","name":"","init":"0","step":"1","lower":"","upper":"","mode":"increment","outputs":2,"x":1980,"y":1560,"wires":[["bc8ce597.52e66","75545630.76c9a8","c6617e9.de4c2"],[]]},{"id":"bc8ce597.52e66","type":"delay","z":"2b6f7cd2.b0d1a4","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"days","rate":"1","nbRateUnits":"","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1980,"y":1600,"wires":[["4d2a7d60.34366c"]]},{"id":"1280becf.6f8129","type":"switch","z":"2b6f7cd2.b0d1a4","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":1630,"y":1560,"wires":[["76846b39.5c8944"]]},{"id":"c6617e9.de4c2","type":"ui_text","z":"2b6f7cd2.b0d1a4","group":"1e7f45a3.99f78a","order":3,"width":3,"height":1,"name":"","label":"Days in Veg","format":"{{msg.payload}}","layout":"row-spread","x":2150,"y":1540,"wires":[]},{"id":"76846b39.5c8944","type":"change","z":"2b6f7cd2.b0d1a4","name":"","rules":[{"t":"change","p":"payload","pt":"msg","from":"1","fromt":"num","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1800,"y":1560,"wires":[["4d2a7d60.34366c"]]},{"id":"d96f0ad6.d7c4e8","type":"function","z":"2b6f7cd2.b0d1a4","name":"maybe somthing like this but with a timer in the while loop","func":"msg1 = {};\nmsg2 = {};\n\nwhile (msg.payload === 0){\n msg1.payload = msg.payoad +1\n}\nwhile (msg.payload == 1){\n msg2.payload = msg.payload + 1\n}\n\nreturn [msg1,msg2];","outputs":2,"noerr":0,"x":1850,"y":1100,"wires":[[],[]]},{"id":"51e31138.899ea","type":"ui_group","z":"","name":"Left","tab":"9caadd41.281e9","order":1,"disp":false,"width":8,"collapse":false},{"id":"1e7f45a3.99f78a","type":"ui_group","z":"","name":"Right","tab":"7dcf1cb5.14a274","order":4,"disp":false,"width":"6","collapse":false},{"id":"9caadd41.281e9","type":"ui_tab","z":"","name":"Ipad","icon":"dashboard","disabled":false,"hidden":false},{"id":"7dcf1cb5.14a274","type":"ui_tab","z":"","name":"Greenhouse","icon":"dashboard","order":2,"disabled":false,"hidden":false}]