Inject node with interval - How to wait for flow to finish before injecting again?

Hello,

I have a flow that I want to run every X seconds, so I'm using the "Inject" node and set interval for X seconds, my goal is to run the flow only if the flow has finished to run,
the problem is that the flow running again before the flow finished and it causing unwanted behavior,
so my question is how can I run a flow every X seconds but only if the flow has finished running?

Thank you :slight_smile:

Hi and welcome.
All depends on timing you wish after the flow finishes.
here are 2 examples of possible solutions

[{"id":"b2cd414314d6cb69","type":"inject","z":"452103ea51141731","name":"stop","props":[{"p":"reset","v":"true","vt":"bool"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":150,"y":3540,"wires":[["8a582f90b300bcda"]]},{"id":"8a582f90b300bcda","type":"change","z":"452103ea51141731","name":"","rules":[{"t":"set","p":"finished","pt":"flow","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":320,"y":3540,"wires":[["652b0d3ab2b55b71"]]},{"id":"652b0d3ab2b55b71","type":"delay","z":"452103ea51141731","name":"simulate flow time","pauseType":"random","timeout":"6","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"4","randomLast":"6","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":470,"y":3480,"wires":[["a00362e6d6b9affd"]]},{"id":"d27964c10afa5663","type":"change","z":"452103ea51141731","name":"","rules":[{"t":"set","p":"finished","pt":"flow","to":"true","tot":"bool"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":3420,"wires":[["652b0d3ab2b55b71"]]},{"id":"a00362e6d6b9affd","type":"change","z":"452103ea51141731","name":"","rules":[{"t":"delete","p":"finished","pt":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":630,"y":3420,"wires":[["a80776679f1372bf"]]},{"id":"b7800bad515d4db1","type":"switch","z":"452103ea51141731","name":"","property":"finished","propertyType":"flow","rules":[{"t":"istype","v":"undefined","vt":"undefined"}],"checkall":"true","repair":false,"outputs":1,"x":230,"y":3420,"wires":[["d27964c10afa5663"]]},{"id":"a80776679f1372bf","type":"debug","z":"452103ea51141731","name":"debug 107","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":3460,"wires":[]},{"id":"49588608ed5577a0","type":"inject","z":"452103ea51141731","name":"test","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"2","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":90,"y":3420,"wires":[["b7800bad515d4db1"]]},{"id":"981b57957a5a55ec","type":"inject","z":"452103ea51141731","name":"stop","props":[{"p":"reset","v":"true","vt":"bool"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":150,"y":3580,"wires":[["cdec8f187c0b9749"]]},{"id":"cdec8f187c0b9749","type":"change","z":"452103ea51141731","name":"","rules":[{"t":"delete","p":"finished","pt":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":3580,"wires":[[]]},{"id":"ae660bb3eba7402a","type":"inject","z":"452103ea51141731","name":"reset","props":[{"p":"reset","v":"true","vt":"bool"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":150,"y":3320,"wires":[["eade73defeaf2348"]]},{"id":"eade73defeaf2348","type":"trigger","z":"452103ea51141731","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"5","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":320,"y":3320,"wires":[["27cc2aae95087f4f"]]},{"id":"1c0bb849507f28ad","type":"inject","z":"452103ea51141731","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"test","payloadType":"str","x":170,"y":3260,"wires":[["eade73defeaf2348"]]},{"id":"27cc2aae95087f4f","type":"delay","z":"452103ea51141731","name":"simulate flow time","pauseType":"random","timeout":"6","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"4","randomLast":"6","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":390,"y":3220,"wires":[["a15b280990b32f57"]]},{"id":"a15b280990b32f57","type":"function","z":"452103ea51141731","name":"function 17","func":"return [msg,msg];","outputs":2,"noerr":0,"initialize":"","finalize":"","libs":[],"x":490,"y":3260,"wires":[["543d77c6f929e577"],["eade73defeaf2348"]]},{"id":"543d77c6f929e577","type":"debug","z":"452103ea51141731","name":"debug 106","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":3260,"wires":[]}]