Counter / Limiter

Hey

I’m trying to limit a sensor - 3 messages within x seconds and then pause for y.

Greetings

This should work for you. Keep in mind when setting the delay, nodered use ms so 5 minutes would be 60000.

[{"id":"d542f98f13ac28ce","type":"counter","z":"24e54e48.fd06f2","name":"count","init":"3","step":"1","lower":"0","upper":"3","mode":"decrement","outputs":2,"x":1590,"y":520,"wires":[["fdcffaab87d5a294"],[]]},{"id":"fdcffaab87d5a294","type":"switch","z":"24e54e48.fd06f2","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"0","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":1770,"y":520,"wires":[["39d679148f3e1367","c11f089f870d5c0d"]]},{"id":"fc5a87cb7e966978","type":"inject","z":"24e54e48.fd06f2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1360,"y":520,"wires":[["d542f98f13ac28ce","fa5685097f2499a2"]]},{"id":"e889e53645d6528d","type":"debug","z":"24e54e48.fd06f2","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":2110,"y":620,"wires":[]},{"id":"fa5685097f2499a2","type":"delay","z":"24e54e48.fd06f2","name":"","pauseType":"delayv","timeout":"0","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"x":1820,"y":660,"wires":[["e889e53645d6528d"]]},{"id":"39d679148f3e1367","type":"change","z":"24e54e48.fd06f2","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":1680,"y":440,"wires":[["d542f98f13ac28ce"]]},{"id":"c11f089f870d5c0d","type":"change","z":"24e54e48.fd06f2","name":"","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"delay","pt":"msg","to":"1000","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":1980,"y":520,"wires":[["fa5685097f2499a2"]]}]
1 Like

awesome! ty

one tiny problem.

If you hit multiple times - it multiple y. But I need a fix value for a reset.

Could provide a little more information? I dont understand what the problem is?