'Best practice in node-red to have an endless flow?
I want to run an endless flow in node-red but don't want to connect the end to the start, or at least want to know if there is a better way of doing this? Like e.g. a node which tells node red to start over or something?
The flow could look like a blank inject which starts once and then having some node which waits for a condition, if this condition happens the flow does something and finishes. But when it finishes, it should start to wait for the condition again.
Hope I explained it understandable :).
Thanks!
Solution 1:[1]
You mean you want the same message to keep going round and round the flow for ever?
If the content of the message can be encapsulated in the payload part of the msg object then you could have a MQTT input node on the start and a publish node at the end and so the object gets published then re-injected at the start. You would probably want to make sure there was a suitable delay node somewhere in the flow as well.
You would kick this off with a inject node that publishes a msg to the same topic when the flow is kicked off.
The other option is to keep all the state in the global context using a function block and just have a inject node at the start that fires at what ever interval you want things to flow "round" the flow.
Both of these are pretty hacky and I think you need to be a clear as to why you want a "never ending flow"
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |