# Variable delay (again) Yeah, sorry

**URL:** <https://discourse.nodered.org/t/variable-delay-again-yeah-sorry/9714>\
**Category:** General\
**Created:** [3 April 2019 06:45 UTC](https://discourse.nodered.org/t/variable-delay-again-yeah-sorry/9714 "2019-04-03T06:45:32Z")\
**Posts on this page:** 5\
**Page:** 1

<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:** [3 April 2019 06:45 UTC](https://discourse.nodered.org/t/variable-delay-again-yeah-sorry/9714/1 "2019-04-03T06:45:33Z")

</div>

To start with: Sorry. I don't get what has happened but something is going on.

Back story:  
I asked a long time ago about how to make an adjustable frequency output from the `delay` node.

I looked in my post/question history ([what I found](https://discourse.nodered.org/t/the-delay-node-not-doing-what-i-want/854)) but for some reason, it isn't "working".

To the best of my knowledge it worked way back when - or I thought it did. (No offence to people who helped me.)

Today I was playing with that part of the flow and somehow it all went pear shaped.

I was mucking about on a couple of my machines, **trying** to optimise a flow. It went yuck and I tried to restore it from another machine.

But when I did that, it remained pear shaped.

This is what I understood is correct/working:

```auto
[{"id":"69fbe069.06a548","type":"inject","z":"b804bcf7.e0c1f","name":"Message","topic":"","payload":"Some value","payloadType":"str","repeat":"","crontab":"","once":true,"onceDelay":0.1,"x":190,"y":150,"wires":[["3a440a04.bc6f36"]]},{"id":"3a440a04.bc6f36","type":"delay","z":"b804bcf7.e0c1f","name":"Variable delay","pauseType":"delayv","timeout":"10","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":460,"y":200,"wires":[["14af84df.b7e05b","14402e6e.be1bea"]]},{"id":"3ead2422.29e19c","type":"change","z":"b804bcf7.e0c1f","name":"","rules":[{"t":"set","p":"interval","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"topic","pt":"msg","to":"interval","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":190,"y":200,"wires":[["d765bbc4.90476","14af84df.b7e05b"]]},{"id":"870d2af8.d9d718","type":"mqtt in","z":"b804bcf7.e0c1f","name":"Scan time","topic":"ALL/SCAN_FREQUENCY","qos":"2","broker":"bf92ca31.fe7038","x":170,"y":250,"wires":[["3ead2422.29e19c"]]},{"id":"14af84df.b7e05b","type":"function","z":"b804bcf7.e0c1f","name":"Variable repeat time","func":"if (msg.topic === \"interval\") {\n context.set(\"interval\", msg.payload);\n msg = null;\n} else {\n var interval = context.get(\"interval\");\n if (interval) msg.delay = interval;\n}\nreturn msg;","outputs":1,"noerr":0,"x":440,"y":250,"wires":[["3a440a04.bc6f36"]]},{"id":"bf92ca31.fe7038","type":"mqtt-broker","z":"","name":"","broker":"192.168.0.99","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"20","cleansession":true,"birthTopic":"SOM","birthQos":"2","birthPayload":"","closeTopic":"","closePayload":"","willTopic":"EOM","willQos":"0","willRetain":"true","willPayload":"'Camera Pi telemetry failure'"}]

```

But that part of the flow doesn't quite do what I want now.  
Not a big thing, but in trying to get it, the problems started.

What I am wanting is that there is an output to (say for now) a debug node that shows the current delay time.

Ultimately it will go to a `text` output node. So before it is shown I will put it through a `function node` to divide the msg.payload by 1000.

I cut/pasted that block of code into the other machine, but for some weird reason:  
rather than seeing it change from 10 seconds to (say) 20, I am getting a long pause then a spurt of outputs, which is not wanted.

I'll try working on it myself, but I don't seem to have a base line.

---

<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:** [3 April 2019 08:46 UTC](https://discourse.nodered.org/t/variable-delay-again-yeah-sorry/9714/2 "2019-04-03T08:46:49Z")

</div>

Please start using the Projects feature with git so that when you mess up you can easily get back to the last working version. That will save us all a lot of time.

---

<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:** [3 April 2019 09:45 UTC](https://discourse.nodered.org/t/variable-delay-again-yeah-sorry/9714/3 "2019-04-03T09:45:05Z")

</div>

Hi Colin.

That is a whole other can of worms for me.  
(And I live in a place called Australia. Our ADSL speeds are comparable to dial up modems on a good day.)

I have backups locally.

In the mean time I got it working again and the flow is/seems to be behaving itself.

I shall spend some time studying what is going on and try to understand it better.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [3 April 2019 09:56 UTC](https://discourse.nodered.org/t/variable-delay-again-yeah-sorry/9714/4 "2019-04-03T09:56:58Z")

</div>

You might want to read the docs on the project feature.  
From the intro:

> They are backed by a Git repository,

You can host that Git repository yourself.

---

<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:** [3 April 2019 09:58 UTC](https://discourse.nodered.org/t/variable-delay-again-yeah-sorry/9714/5 "2019-04-03T09:58:11Z")

</div>

Ah, thanks.

I appreciate that. I shall put it on the job list/queue.
