# Adding a delay to injections

**URL:** <https://discourse.nodered.org/t/adding-a-delay-to-injections/48439>\
**Category:** General\
**Created:** [15 July 2021 07:01 UTC](https://discourse.nodered.org/t/adding-a-delay-to-injections/48439 "2021-07-15T07:01:10Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![binderth](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/binderth/32/35124_2.png) [@binderth](https://discourse.nodered.org/u/binderth)\
**Post date:** [15 July 2021 07:01 UTC](https://discourse.nodered.org/t/adding-a-delay-to-injections/48439/1 "2021-07-15T07:01:10Z")

</div>

I have a few sensors, I'd like to poll regularly, is there a recommended way to add a delay for that?  
e.g.:

```auto
[{"id":"f333eff6.397c1","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"2c9cd50b.09aca2","type":"inject","z":"f333eff6.397c1","name":"Temp-Sued","props":[{"p":"sensor","v":"tempSued","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"6","crontab":"","once":true,"onceDelay":0.1,"topic":"26.E1CD92010000/temperature","payloadType":"str","x":690,"y":300,"wires":[["8d78bdc3.c230a8"]]},{"id":"8d78bdc3.c230a8","type":"owfs","z":"f333eff6.397c1","name":"1-wire","uncached":false,"mode":"read","host":"192.168.78.10","port":4304,"paths":[],"x":930,"y":300,"wires":[[]]}]

```

So, I'd like to wait like 2secs for that sensor and 5secs for the next?

_or other way round: can I read-out all 1-wire sensors ootb?_

> [@Onewire sensors: read all out](https://discourse.nodered.org/t/onewire-sensors-read-all-out/48440):
>
> I'd like to read out all my onewire sensors at once, but only get one? [{"id":"d6d27eeb.c278a8","type":"inject","z":"97b191db.235b1","d":true,"name":"Temps","props":[],"repeat":"6","crontab":"","once":true,"onceDelay":0.1,"topic":"","x":400,"y":200,"wires":[["11c1a21e.e71a3e"]]},{"id":"11c1a21e.e71a3e","type":"owfs","z":"97b191db.235b1","name":"1-wire","uncached":false,"mode":"read","host":"192.168.78.10","port":4304,"paths":["28.282DE9050000/temperature","28.34A2E9050000/temperature","28.7A3BE…

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [15 July 2021 07:06 UTC](https://discourse.nodered.org/t/adding-a-delay-to-injections/48439/2 "2021-07-15T07:06:56Z")

</div>

Sorry, but what you posted doesn't really help.

You also may need to edit that new bit of code so it can be exported.

---

<div class="post-metadata">

**Author:** ![binderth](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/binderth/32/35124_2.png) [@binderth](https://discourse.nodered.org/u/binderth)\
**Post date:** [15 July 2021 07:27 UTC](https://discourse.nodered.org/t/adding-a-delay-to-injections/48439/3 "2021-07-15T07:27:37Z")

</div>

Sorry, if it was unclear - I guess, you need [node-red-contrib-owfs : owfs](https://flows.nodered.org/node/node-red-contrib-owfs) for importing my flow.

But, apart from that, my question is:

1. you have different endpoints on the same machine/technology
2. you want to poll from that endpoints regularly
3. you want to reduce load from that machine/technology

one solution to 3. was to insert delays to the injections. As it is right now (or as I see it), you can use timestamp with an interval of xx sec/min/..., but you can't use like cron-like syntax, so that I could say:

- sensor1: every 5min 2secs
- sensor2: every 5min 5secs
- sensor3: every 5min 8secs
- ...

hope, it became more clear now... 😉

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [15 July 2021 07:32 UTC](https://discourse.nodered.org/t/adding-a-delay-to-injections/48439/4 "2021-07-15T07:32:48Z")

</div>

> [@binderth](#):
>
> So, I'd like to wait like 2secs for that sensor and 5secs for the next?

That's what is stumping me.

What do you mean?

Do you mean:

The first pulse happens 2 seconds after start and all others are at 5?

---

<div class="post-metadata">

**Author:** ![binderth](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/binderth/32/35124_2.png) [@binderth](https://discourse.nodered.org/u/binderth)\
**Post date:** [15 July 2021 07:52 UTC](https://discourse.nodered.org/t/adding-a-delay-to-injections/48439/5 "2021-07-15T07:52:06Z")

</div>

> [@binderth](#):
>
> - sensor1: every 5min 2secs
> - sensor2: every 5min 5secs
> - sensor3: every 5min 8secs
> - ...

I guess, your answer overlapped my new post. My goal is to avoid reading out in parallel, which - depending on the technology - doesn't work, so I'd like to add tiny intervals in the read-outs, so to avoid parallel polls...

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [15 July 2021 07:56 UTC](https://discourse.nodered.org/t/adding-a-delay-to-injections/48439/6 "2021-07-15T07:56:28Z")

</div>

So why not send a _signal_ and put `delay` nodes to send it to the sensors?

A bit like this:

 ![Screenshot from 2021-07-15 17-55-47](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/d/3da0df49fdd3205669e81294fc4e72869df5aebc.png)

Values in the `delay` node is nominal.

---

<div class="post-metadata">

**Author:** ![binderth](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/binderth/32/35124_2.png) [@binderth](https://discourse.nodered.org/u/binderth)\
**Post date:** [15 July 2021 08:08 UTC](https://discourse.nodered.org/t/adding-a-delay-to-injections/48439/7 "2021-07-15T08:08:30Z")

</div>

Thanks - I was blind! 😉

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [15 July 2021 08:08 UTC](https://discourse.nodered.org/t/adding-a-delay-to-injections/48439/8 "2021-07-15T08:08:56Z")

</div>

Don't worry. We all have our bad days.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [15 July 2021 08:46 UTC](https://discourse.nodered.org/t/adding-a-delay-to-injections/48439/9 "2021-07-15T08:46:50Z")

</div>

If you use multiple owfs nodes you shouldn't need to delay them, I advise against using the checkbox method in the node., it is safer to explicitly set the topic. Using the checkboxes a problem can arise if you open the node when one of the sensors is not available, it will be removed from the list of sensors to be fetched and will not automatically be re-included when the sensor recovers, unless you open the node again. I do it like this  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/5/151ff972a1a4eb30209a7a8151982ec2df7afe81.png)

In addition it is worth looking at aliasing in owserver. It is very easy to do that and then you can use addresses like `/bedroom_temp/temperature`rather than `26.E1CD92010000/temperature`.

---

<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:** [29 July 2021 08:47 UTC](https://discourse.nodered.org/t/adding-a-delay-to-injections/48439/10 "2021-07-29T08:47:09Z")

</div>

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