Build rate limit into function node code?

Is it possible to add the rate limit into the function node so that all the code is in one node?
This is what I have now:

[{"id":"1d6988c5.b577e7","type":"debug","z":"5aa7d621.d84518","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":970,"y":1470,"wires":[]},{"id":"5b4a42ab.8c044c","type":"delay","z":"5aa7d621.d84518","name":"1","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"30","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"x":800,"y":1470,"wires":[["1d6988c5.b577e7"]]},{"id":"2a1356dc.57d66a","type":"function","z":"5aa7d621.d84518","name":"Site 9999 Level >= 100mm","func":"if (msg.payload.includes(\"Site Info\"))\n{\n    msg.payload = \"1010101 Data\";\n    return msg;\n}\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":580,"y":1470,"wires":[["5b4a42ab.8c044c"]]},{"id":"a5a168ef.7c06e8","type":"inject","z":"5aa7d621.d84518","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"Site Info","payloadType":"str","x":350,"y":1470,"wires":[["2a1356dc.57d66a"]]}]

Well I'm sure you could - but the point of Node-RED is to be easily "read" by following the flow, and to re-use existing functionality/nodes. But up to you.

An alternative - if you simply want to simplify how your flow looks - is to wrap the nodes in a sub-flow.

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