Inject 20 times with 1 sec intervals

Is there a way to trigger an inject 20 times with 1 sec intervals?

yes.

One way...
inject node set to repeat every 1s → function node (write for loop calling node.send(msg) )


Another way...

inject node set to repeat every 1s & set to send a JSON payload of [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19] → split node

Sorry my bad, I made the question wrong

I meant something like this but 20 times

Captura2

really still not clear.

Do you want

  • 20 messages spaced out over 1 second?
  • 20 messages sent as fast as possible every 1 second?
  • 20 messages 1 second apart? (only when triggered)
  • 20 messages spaced out across one minute?

The first one, 20 messages spaced out over 1 sec (when triggered)

[{"id":"cc1aa912.9040b8","type":"inject","z":"b872cb4b.5a6448","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19, 20]","payloadType":"json","x":810,"y":320,"wires":[["799db71.008f048"]]},{"id":"799db71.008f048","type":"split","z":"b872cb4b.5a6448","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":980,"y":320,"wires":[["23ac00a2.0181d"]]},{"id":"23ac00a2.0181d","type":"delay","z":"b872cb4b.5a6448","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"20","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1150,"y":320,"wires":[["3e92a72f.979108"]]},{"id":"3e92a72f.979108","type":"debug","z":"b872cb4b.5a6448","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1330,"y":320,"wires":[]}]

looking at your picture

... it looks more like you want : 1 MESSAGE - EVERY 1 SEC

in which case this is better...

[{"id":"cc1aa912.9040b8","type":"inject","z":"b872cb4b.5a6448","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19, 20]","payloadType":"json","x":810,"y":320,"wires":[["799db71.008f048"]]},{"id":"799db71.008f048","type":"split","z":"b872cb4b.5a6448","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":980,"y":320,"wires":[["23ac00a2.0181d"]]},{"id":"23ac00a2.0181d","type":"delay","z":"b872cb4b.5a6448","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1140,"y":320,"wires":[["3e92a72f.979108"]]},{"id":"3e92a72f.979108","type":"debug","z":"b872cb4b.5a6448","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1330,"y":320,"wires":[]}]

its basically the same but the rate limiter is set to release 1 msg every 1 sec

here it is via a function node...

[{"id":"cc1aa912.9040b8","type":"inject","z":"b872cb4b.5a6448","name":"send 20","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"20","payloadType":"num","x":1770,"y":140,"wires":[["4aef892d.e42408"]]},{"id":"4aef892d.e42408","type":"function","z":"b872cb4b.5a6448","name":"generate x messages","func":"var no_of_messages_to_send = msg.payload;\nfor (let index = 0; index < no_of_messages_to_send; index++) {\n    msg.payload = index;\n    node.send(msg);\n}\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":1980,"y":140,"wires":[["2f301ae3.d5eee6"]]},{"id":"2f301ae3.d5eee6","type":"delay","z":"b872cb4b.5a6448","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":2010,"y":200,"wires":[["a23ffbf4.3891e8"]]},{"id":"a23ffbf4.3891e8","type":"debug","z":"b872cb4b.5a6448","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":2050,"y":260,"wires":[]},{"id":"eec3b112.30923","type":"inject","z":"b872cb4b.5a6448","name":"send 5","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"5","payloadType":"num","x":1770,"y":200,"wires":[["4aef892d.e42408"]]}]

Thx that's what i needed!!

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