# Dynamic modification of time interval (Batch node)

**URL:** <https://discourse.nodered.org/t/dynamic-modification-of-time-interval-batch-node/31644>\
**Category:** General\
**Created:** [17 August 2020 08:23 UTC](https://discourse.nodered.org/t/dynamic-modification-of-time-interval-batch-node/31644 "2020-08-17T08:23:14Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![skoumo01](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@skoumo01](https://discourse.nodered.org/u/skoumo01)\
**Post date:** [17 August 2020 08:23 UTC](https://discourse.nodered.org/t/dynamic-modification-of-time-interval-batch-node/31644/1 "2020-08-17T08:23:14Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [17 August 2020 08:37 UTC](https://discourse.nodered.org/t/dynamic-modification-of-time-interval-batch-node/31644/2 "2020-08-17T08:37:52Z")

</div>

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 ?

---

<div class="post-metadata">

**Author:** ![skoumo01](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@skoumo01](https://discourse.nodered.org/u/skoumo01)\
**Post date:** [17 August 2020 08:46 UTC](https://discourse.nodered.org/t/dynamic-modification-of-time-interval-batch-node/31644/3 "2020-08-17T08:46:01Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [17 August 2020 09:07 UTC](https://discourse.nodered.org/t/dynamic-modification-of-time-interval-batch-node/31644/4 "2020-08-17T09:07:06Z")

</div>

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 🙂 )

---

<div class="post-metadata">

**Author:** ![skoumo01](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@skoumo01](https://discourse.nodered.org/u/skoumo01)\
**Post date:** [17 August 2020 09:20 UTC](https://discourse.nodered.org/t/dynamic-modification-of-time-interval-batch-node/31644/5 "2020-08-17T09:20:56Z")

</div>

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](https://discourse.nodered.org/t/inject-node-repeat-stuck-if-it-can-be-set-externally/3601/3)] 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.

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [17 August 2020 09:42 UTC](https://discourse.nodered.org/t/dynamic-modification-of-time-interval-batch-node/31644/6 "2020-08-17T09:42:11Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![skoumo01](https://avatars.discourse-cdn.com/v4/letter/s/e47774/32.png) [@skoumo01](https://discourse.nodered.org/u/skoumo01)\
**Post date:** [17 August 2020 09:58 UTC](https://discourse.nodered.org/t/dynamic-modification-of-time-interval-batch-node/31644/7 "2020-08-17T09:58:09Z")

</div>

Great idea(!)

Thank you; will check it out 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [31 August 2020 09:58 UTC](https://discourse.nodered.org/t/dynamic-modification-of-time-interval-batch-node/31644/8 "2020-08-31T09:58:13Z")

</div>

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