Using slider to change rate limit

Hi, I'm pretty new here and I have a little project going.
I need to change the rate of messages passing through the delay node using a slider.
The point of this flow is that the user can start to log values using the toggle switch and change the rate which controls the number of log-points going to the database.

I just want to know if it's possible? or am I off to a wild goose chase?

[{"id":"c16a0042.ed6f9","type":"inject","z":"81c9c805.d23178","name":"","topic":"","payload":"","payloadType":"date","repeat":"5","crontab":"","once":false,"onceDelay":0.1,"x":170,"y":320,"wires":[["6a85f980.d6dfe8"]]},{"id":"295ff0d4.ced1f","type":"ui_gauge","z":"81c9c805.d23178","name":"","group":"d3aee454.a07f08","order":1,"width":0,"height":0,"gtype":"gage","title":"SA","label":"Kohm","format":"{{value}}","min":0,"max":"1000","colors":["#ff0000","#e6e600","#00ff00"],"seg1":"50","seg2":"100","x":510,"y":320,"wires":[]},{"id":"83faeed8.1ad9b","type":"ui_chart","z":"81c9c805.d23178","name":"","group":"d3aee454.a07f08","order":3,"width":0,"height":0,"label":"SA","chartType":"line","legend":"false","xformat":"HH:mm","interpolate":"linear","nodata":"","dot":false,"ymin":"00:00","ymax":"04:00","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#1f77b4","#aec7e8","#ff7f0e","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5"],"useOldStyle":false,"outputs":1,"x":510,"y":360,"wires":[[]]},{"id":"6a85f980.d6dfe8","type":"random","z":"81c9c805.d23178","name":"","low":"1","high":"1000","inte":"true","property":"payload","x":320,"y":320,"wires":[["295ff0d4.ced1f","83faeed8.1ad9b","3066911f.45b4ee"]]},{"id":"81eab8d1.a9cb88","type":"function","z":"81c9c805.d23178","name":"format database","func":"msg.temp = msg.payload\nmsg.topic = \"INSERT INTO SA(`verdi`) VALUES ( \"+ msg.temp + \" );\"\nreturn msg;","outputs":1,"noerr":0,"x":1080,"y":260,"wires":[[]]},{"id":"3eb77bac.71e754","type":"ui_switch","z":"81c9c805.d23178","name":"","label":"Logg","tooltip":"","group":"d3aee454.a07f08","order":0,"width":0,"height":0,"passthru":false,"decouple":"false","topic":"gate","style":"","onvalue":"true","onvalueType":"bool","onicon":"","oncolor":"","offvalue":"false","offvalueType":"bool","officon":"","offcolor":"","x":310,"y":260,"wires":[["3066911f.45b4ee"]]},{"id":"3066911f.45b4ee","type":"function","z":"81c9c805.d23178","name":"gate","func":"// read (or initialize) gate state\nvar gateIsOpen = context.get(\"gateIsOpen\") || false;\n\n//message is from switch\nif(msg.topic === \"gate\"){\n gateIsOpen = msg.payload;\n // store the gate state \n context.set(\"gateIsOpen\",gateIsOpen);\n}\n\n// message is from other sources\nelse{\n if(gateIsOpen === true){\n node.status({fill:\"green\",shape:\"ring\",text:\"gate is open\"});\n // send through the original message\n return msg;\n }\n else{\n //just display the status of gate\n node.status({fill:\"red\",shape:\"ring\",text:\"gate is closed\"});\n }\n}\n\n","outputs":1,"noerr":0,"x":510,"y":260,"wires":[["48a104a3.3c195c"]]},{"id":"86c14910.9a8838","type":"ui_slider","z":"81c9c805.d23178","name":"","label":"slider","tooltip":"","group":"d3aee454.a07f08","order":3,"width":0,"height":0,"passthru":true,"outs":"end","topic":"delay","min":0,"max":"60","step":1,"x":510,"y":160,"wires":[["48a104a3.3c195c"]]},{"id":"9f221c53.6c1c3","type":"debug","z":"81c9c805.d23178","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":1130,"y":200,"wires":[]},{"id":"48a104a3.3c195c","type":"function","z":"81c9c805.d23178","name":"Set delay","func":"if (msg.topic === \"delay\") {\n    context.set(\"delay\", msg.payload);\n    msg = null;\n} else {\n    delay = context.get(\"delay\");\n    if (delay === undefined) delay = 1000;  // default delay ms\n    msg.delay = delay;\n}\nreturn msg;","outputs":1,"noerr":0,"x":720,"y":260,"wires":[["431d1929.f9b6f8"]]},{"id":"431d1929.f9b6f8","type":"delay","z":"81c9c805.d23178","name":"","pauseType":"rate","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":890,"y":260,"wires":[["9f221c53.6c1c3"]]},{"id":"d3aee454.a07f08","type":"ui_group","z":"","name":"Test 1","tab":"743c9136.24d3e","order":1,"disp":true,"width":"6","collapse":false},{"id":"743c9136.24d3e","type":"ui_tab","z":"","name":"Test","icon":"dashboard","order":6,"disabled":false,"hidden":false}]

Thanks in advance for any help.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.