Dynamic modification of time interval (Batch node)

Hello, I would like to ask whether it is possible to set up a Batch node in a way that it uses an externally defined time interval for grouping the received messages; e.g. using the value of a variable that gets updated every X seconds.

If not, do you have any suggestions on how to group messages every X seconds, keeping in mind that X must get updated without re-deploying the flow in use?

Welcome to the forum.

I don't believe it is possible to use a dynamic timeframe.

Is there something unique available in the input messages that you could possibly use as key for grouping ?

Thank you for the reply.

Sorry for answering your question with a question, but are you, in essence, suggesting to make use of the msg.topic with the Concatenate Sequences mode of the Batch node?

Not necessarily, could you perhaps post an output from a debug node with some example data ?
Or explain what data you are trying to process and what the expected output is ? (as there are many roads to Rome in node-red :slight_smile: )

Unfortunately, I don't really have a specific example at the moment, as we are still in the brainstorming phase of our project, but what I am trying to do is create some sort of a buffering layer using node-red.

If it helps, the concept is that I want to create a time-based buffer to batch together sensor/device measurements in order to batch-insert them into influxDB. Using the Batch node currently allows us to use a fixed time-interval for all the sensors, but this is quite inflexible for our case...

*Update to my question: I have found this [Inject node - repeat. Stuck if it can be set externally] question that may aid in changing the time interval of the Batch node, but I am new to node-red and I am not sure how adapt it to my case yet.

Depending on the amount of data you are expecting in the timeframe (how long, how many sensors/payload), you could store them temporarily in context (node/flow/global) and once your timer has exceeded, set the time and batch it to influxdb and clear the context for the next batch.

Great idea(!)

Thank you; will check it out :slight_smile:

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