# Trigger node help - please

**URL:** https://discourse.nodered.org/t/trigger-node-help-please/11728
**Category:** General
**Created:** [31 May 2019 11:18 UTC](https://discourse.nodered.org/t/trigger-node-help-please/11728 "2019-05-31T11:18:14Z")
**Posts on this page:** 11
**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: [31 May 2019 11:18 UTC](https://discourse.nodered.org/t/trigger-node-help-please/11728/1 "2019-05-31T11:18:14Z")

</div>

Forgive me if I've asked this before, but from what I remember it was the `DELAY` node, not the `TRIGGER` node.

Here's the part of the flow.....

```auto
[{"id":"178ae8cd.12b0d7","type":"trigger","z":"15af81c5.64999e","op1":"","op2":"2","op1type":"nul","op2type":"num","duration":"60","extend":false,"units":"min","reset":"reset","bytopic":"all","name":"Dusk/Night 2","x":420,"y":2830,"wires":[["aaab7a55.a5b48"]]},{"id":"a7e53875.6f5cd8","type":"trigger","z":"15af81c5.64999e","op1":"","op2":"3","op1type":"nul","op2type":"num","duration":"90","extend":false,"units":"min","reset":"reset","bytopic":"all","name":"Dusk/Night 3","x":420,"y":2870,"wires":[["aaab7a55.a5b48"]]},{"id":"b9cb98a8.35ed48","type":"trigger","z":"15af81c5.64999e","op1":"","op2":"OFF","op1type":"nul","op2type":"str","duration":"120","extend":false,"units":"min","reset":"reset","bytopic":"all","name":"Dusk/Night OFF","x":429,"y":2909,"wires":[["aaab7a55.a5b48"]]},{"id":"4ebde882.899c88","type":"trigger","z":"15af81c5.64999e","op1":"","op2":"1","op1type":"nul","op2type":"num","duration":"30","extend":false,"units":"min","reset":"reset","bytopic":"all","name":"Dusk/Night 1","x":420,"y":2790,"wires":[["aaab7a55.a5b48"]]},{"id":"1ebea0cd.4ef777","type":"inject","z":"15af81c5.64999e","name":"","topic":"","payload":"trigger","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":200,"y":2850,"wires":[["4ebde882.899c88","178ae8cd.12b0d7","a7e53875.6f5cd8","b9cb98a8.35ed48"]]},{"id":"aaab7a55.a5b48","type":"function","z":"15af81c5.64999e","name":"Do what ever","func":"\nreturn msg;","outputs":1,"noerr":0,"x":690,"y":2850,"wires":[[]]}]

```

Understand this is not **the** flow, but a cut down part.

Something happens.  
After 30 minutes, a message is sent.  
After 60 minutes, another message is sent.  
After 90 minutes, (you get it)

What I am wanting to do is be able to adjust the step size between the messages.

Say change it from 30 to 40, 50 or 60 minutes.

I've read the info and I don't think it is possible.

Fair enough if so. But I am open to how I could do what I want.

Much appreciated.

---

<div class="post-metadata">

### Author: ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)
#### Post date: [31 May 2019 12:48 UTC](https://discourse.nodered.org/t/trigger-node-help-please/11728/2 "2019-05-31T12:48:57Z")

</div>

> [@Trying\_to\_learn](#):
>
> Forgive me if I've asked this before, but from what I remember it was the `DELAY` node, not the `TRIGGER` node.

I found your previous inquire. At that point in time you asked how to change the interval if using the inject node. Colin proposed a flow using the delay node. I found it a smart solution and save the flow in my favorites folder.

> [@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):
>
> Probably dumb, but here goes: Is there a way to edit/change/set the repeat interval with flow or global variables? What I am wanting to do: As is, I have an inject node running injects every 10 seconds. To change that, I have to edit the node and deploy. I would like to be able to adjust the time. Am I missing a better suited node, or can I control the INJECT node with global. or flow. variables? Thanks.

---

<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: [31 May 2019 12:54 UTC](https://discourse.nodered.org/t/trigger-node-help-please/11728/3 "2019-05-31T12:54:08Z")

</div>

Yes, but that sends an output at a given interval.

This more sends one output (per node) when it is triggered/"stimulated".

When an event happens I want a sequence of things happening (once) after then at given times.

As is, it is 30 minutes.

If I want to change it to 45, I have to edit all the nodes and add 45 to the time.

If I could send them that value I could send `45` and a function node would do all the maths and send the resulting values to the respective nodes.

So the first one would get 45.  
The second would get 90  
The next would get..... 135.

And so on.

Then, when the trigger event happens: after 45 minutes, node 1 would send its message (once)  
Then another 45 minutes later: node 2 would send its message (once)  
Another 45 minutes: node 3 would do it's thing.

In the previous one, these times would repeat.

In this case they are one off events all triggered by an initial input.

---

<div class="post-metadata">

### Author: ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)
#### Post date: [31 May 2019 13:16 UTC](https://discourse.nodered.org/t/trigger-node-help-please/11728/4 "2019-05-31T13:16:59Z")

</div>

I see. Perhaps something like posted in the below post from the old forum ?

 ![r-01](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/08b058db5117f784f3c0b213f9f659ad2e8e790e.png)

[https://groups.google.com/forum/#!topic/node-red/vtvuXaLY0Zk](https://groups.google.com/forum/#!topic/node-red/vtvuXaLY0Zk)

The first function node is where you define the timing.

It is easy to modify the amount of "triggers" (virtual triggers) and what data to send for each one.

---

<div class="post-metadata">

### Author: ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)
#### Post date: [31 May 2019 13:32 UTC](https://discourse.nodered.org/t/trigger-node-help-please/11728/5 "2019-05-31T13:32:45Z")

</div>

In which case the modified version to suit your needs would be:

and you are free to change any delay for each step (in a single place):

```auto
// Define runtime1 (4 seconds)
msg.runtime1 = 4*1000;

// Define runtime2 (2 seconds)
msg.runtime2 = 2*1000;

// Define runtime3 (7 seconds)
msg.runtime3 = 7*1000;

// Next to be activated is number 1
msg.next = 1;

//Stop criteria is false
global.set("StopFan",false);

return msg;

```

```auto
[{"id":"df15b4d6.262448","type":"tab","label":"Flow 51","disabled":false,"info":""},{"id":"2109e1c9.fad29e","type":"function","z":"df15b4d6.262448","name":"Cycle next fan","func":"switch (msg.next) {\n \n case 1:\n msg.delay = msg.runtime1;\n msg.payload = 1; \n msg.next = 2;\n break;\n case 2:\n msg.delay = msg.runtime2;\n msg.payload = 2;\n msg.next = 3;\n break; \n case 3:\n msg.delay = msg.runtime3;\n msg.payload = 3;\n msg.next = 1;\n break; \n \n}\n\n return msg;","outputs":1,"noerr":0,"x":500,"y":120,"wires":[["2941900c.9c37","d5fbd731.0bf9d8"]]},{"id":"512bcdf6.2aead4","type":"inject","z":"df15b4d6.262448","name":"Start Flow","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"","x":140,"y":120,"wires":[["39c4fbe2.055824"]]},{"id":"d5fbd731.0bf9d8","type":"function","z":"df15b4d6.262448","name":"Test Stop","func":"// user commanded stopping fans\nif (global.get(\"StopFan\")) msg.next = 4;\nreturn msg;","outputs":1,"noerr":0,"x":423.33331298828125,"y":259.555552482605,"wires":[["1567c1f3.9bce9e"]]},{"id":"39c4fbe2.055824","type":"function","z":"df15b4d6.262448","name":"Initialize","func":"\n// Define runtime1 (3 seconds)\nmsg.runtime1 = 3*1000;\n\n// Define runtime2 (6 seconds)\nmsg.runtime2 = 6*1000;\n\n// Define runtime3 (9 seconds)\nmsg.runtime3 = 9*1000;\n\n// Next to be activated is number 1\nmsg.next = 1;\n\n//Stop criteria is false\nglobal.set(\"StopFan\",false);\n\nreturn msg;","outputs":1,"noerr":0,"x":300,"y":120,"wires":[["2109e1c9.fad29e"]]},{"id":"1567c1f3.9bce9e","type":"delay","z":"df15b4d6.262448","name":"","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":603.3333129882812,"y":259.555552482605,"wires":[["2109e1c9.fad29e"]]},{"id":"2941900c.9c37","type":"debug","z":"df15b4d6.262448","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":680,"y":120,"wires":[]}]

```

---

<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: [31 May 2019 22:24 UTC](https://discourse.nodered.org/t/trigger-node-help-please/11728/6 "2019-05-31T22:24:12Z")

</div>

Thanks.

It loops back and keeps going, but I think I can work out how to make it stop itself after 1 loop.

--via edit--  
Ok, I am dumb.  
In the initialize `function` node I see:

```auto
//Stop criteria is false
global.set("StopFan",false);

```

So, reading that I set "StopFan" to `true` to stop it.

But then when I look at the Test Stop node I see:

```auto
// user commanded stopping fans
if (global.get("StopFan")) msg.next = 4;
return msg;

```

`4`, not `true`/`false`/

I've obviously missed something.

I'll keep looking though.

--progress--

Ok, this is what I got to do the **one time** loop.

```auto
[{"id":"c5192ec4.39a838","type":"function","z":"6c223db0.773914","name":"Cycle next fan","func":"switch (msg.next) {\n \n case 1:\n msg.delay = msg.runtime1;\n msg.payload = 1; \n msg.next = 2;\n break;\n case 2:\n msg.delay = msg.runtime2;\n msg.payload = 2;\n msg.next = 3;\n break; \n case 3:\n msg.delay = msg.runtime3;\n msg.payload = 3;\n msg.next = 1;\n break; \n \n}\n\n return msg;","outputs":1,"noerr":0,"x":500,"y":120,"wires":[["b40c043.9cbd778","344786ea.b93c02","3846424f.31e166"]]},{"id":"57d90848.942d68","type":"inject","z":"6c223db0.773914","name":"Start Flow","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"","x":140,"y":120,"wires":[["7fea713a.2a3aa"]]},{"id":"344786ea.b93c02","type":"function","z":"6c223db0.773914","name":"Test Stop","func":"// user commanded stopping fans\nif (global.get(\"StopFan\")) msg.next = 4;\nreturn msg;","outputs":1,"noerr":0,"x":423.33331298828125,"y":259.555552482605,"wires":[["d64d6ce1.b96f8"]]},{"id":"7fea713a.2a3aa","type":"function","z":"6c223db0.773914","name":"Initialize","func":"\n// Define runtime1 (3 seconds)\nmsg.runtime1 = 3*1000;\n\n// Define runtime2 (6 seconds)\nmsg.runtime2 = 6*1000;\n\n// Define runtime3 (9 seconds)\nmsg.runtime3 = 9*1000;\n\n// Next to be activated is number 1\nmsg.next = 1;\n\n//Stop criteria is false\nglobal.set(\"StopFan\",false);\n\nreturn msg;","outputs":1,"noerr":0,"x":300,"y":120,"wires":[["c5192ec4.39a838"]]},{"id":"d64d6ce1.b96f8","type":"delay","z":"6c223db0.773914","name":"","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":603.3333129882812,"y":259.555552482605,"wires":[["c5192ec4.39a838"]]},{"id":"b40c043.9cbd778","type":"debug","z":"6c223db0.773914","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","x":680,"y":120,"wires":[]},{"id":"7ce8975b.74c168","type":"change","z":"6c223db0.773914","name":"","rules":[{"t":"set","p":"reset","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":310,"wires":[["d64d6ce1.b96f8"]]},{"id":"3846424f.31e166","type":"switch","z":"6c223db0.773914","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"3","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":240,"y":310,"wires":[["7ce8975b.74c168"]]}]

```

---

<div class="post-metadata">

### Author: ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)
#### Post date: [31 May 2019 23:18 UTC](https://discourse.nodered.org/t/trigger-node-help-please/11728/7 "2019-05-31T23:18:03Z")

</div>

I misread your OP. Only now I realised that you don´t need the flow to keep looping until it receives some command to stop. It is just one loop. In such case the flow could be much simpler. All you need is to make the loop to read the pre set values and then send a msg.reset to the delay node.

---

<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: [31 May 2019 23:21 UTC](https://discourse.nodered.org/t/trigger-node-help-please/11728/8 "2019-05-31T23:21:08Z")

</div>

I've nearly got it.

This is (now) what I have:

```auto
[{"id":"c5192ec4.39a838","type":"function","z":"6c223db0.773914","name":"Cycle next fan","func":"switch (msg.next) {\n \n case 1:\n msg.delay = msg.runtime1;\n msg.payload = 1; \n msg.next = 2;\n break;\n case 2:\n msg.delay = msg.runtime2;\n msg.payload = 2;\n msg.next = 3;\n break; \n case 3:\n msg.delay = msg.runtime3;\n msg.payload = 3;\n msg.next = 4;\n break; \n \n case 4:\n msg.delay = msg.runtime4;\n msg.payload = 4;\n msg.next = 5;\n break; \n case 5:\n msg.delay = msg.runtime4;\n msg.payload = 5;\n msg.next = 1;\n break; \n\n}\n\n return msg;","outputs":1,"noerr":0,"x":500,"y":120,"wires":[["b40c043.9cbd778","3846424f.31e166","6aa67fb0.e1aca"]]},{"id":"57d90848.942d68","type":"inject","z":"6c223db0.773914","name":"Start Flow","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"","x":140,"y":120,"wires":[["7fea713a.2a3aa"]]},{"id":"7fea713a.2a3aa","type":"function","z":"6c223db0.773914","name":"Initialize","func":"\n// Define runtime1 (3 seconds)\nmsg.runtime1 = 3*1000;\n\n// Define runtime2 (6 seconds)\nmsg.runtime2 = 3*1000;\n\n// Define runtime3 (9 seconds)\nmsg.runtime3 = 3*1000;\n\n// Define runtime4\nmsg.runtime4 = 3*1000;\n\n// Define runtime5\nmsg.runtime5 = 3*1000;\n\n// Next to be activated is number 1\nmsg.next = 1;\n\nreturn msg;","outputs":1,"noerr":0,"x":300,"y":120,"wires":[["c5192ec4.39a838"]]},{"id":"d64d6ce1.b96f8","type":"delay","z":"6c223db0.773914","name":"","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":600,"y":280,"wires":[["c5192ec4.39a838"]]},{"id":"b40c043.9cbd778","type":"debug","z":"6c223db0.773914","name":"","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"payload","targetType":"msg","x":720,"y":140,"wires":[]},{"id":"7ce8975b.74c168","type":"change","z":"6c223db0.773914","name":"stop","rules":[{"t":"set","p":"reset","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":260,"wires":[["d64d6ce1.b96f8"]]},{"id":"3846424f.31e166","type":"switch","z":"6c223db0.773914","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"4","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":230,"y":280,"wires":[["7ce8975b.74c168","a20bf21d.c17ac8"],["d64d6ce1.b96f8"]]},{"id":"6aa67fb0.e1aca","type":"debug","z":"6c223db0.773914","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","x":700,"y":100,"wires":[]},{"id":"a20bf21d.c17ac8","type":"change","z":"6c223db0.773914","name":"off","rules":[{"t":"set","p":"payload","pt":"msg","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":220,"wires":[["6aa67fb0.e1aca","b40c043.9cbd778"]]}]

```

But it isn't quite perfect.

If I want to "exit on 4" and I make the switch select the 4, I still see the next digit before I get the "OFF" message.

_luckily_ that isn't a problem and the code can deal with that.

I have applied it to the real flow and will have to wait for tonight to see if it works.  
(Though I may give it a poke before then if I feel lucky.)

---

<div class="post-metadata">

### Author: ![Andrei](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/andrei/32/10446_2.png) [@Andrei](https://discourse.nodered.org/u/Andrei)
#### Post date: [1 June 2019 00:10 UTC](https://discourse.nodered.org/t/trigger-node-help-please/11728/9 "2019-06-01T00:10:10Z")

</div>

Indeed, you got the idea

I had a look in your very first flow, the one that uses the trigger nodes. The behavior of that flow is to first wait for a delay and only then send the first message. The one i suggested behaves differently: it first sends the message and then wait for a delay.

Here a modified flow that I think is better (but still uses an uggly loop):

```auto
[{"id":"7b4467ef.fde5a8","type":"tab","label":"Variable timer","disabled":false,"info":""},{"id":"d1640e93.e60bc","type":"function","z":"7b4467ef.fde5a8","name":"Cycle next ","func":"switch (msg.next) {\n \n case 1:\n msg.delay = msg.runtime1;\n msg.payload = 1; \n msg.next = 2;\n break;\n case 2:\n msg.delay = msg.runtime2;\n msg.payload = 2;\n msg.next = 3;\n break; \n case 3:\n msg.delay = msg.runtime3;\n msg.payload = 3;\n global.set(\"StopFan\",true);\n msg.next = 4;\n break; \n case 4:\n msg.delay = msg.runtime4;\n msg.payload = \"off\";\n msg.next = 5;\n break;\n case 5:\n msg.reset = true;\n break; \n}\n\n return msg;","outputs":1,"noerr":0,"x":530,"y":200,"wires":[["6c8a9344.dc08ec"]]},{"id":"fcb494c.c71ed68","type":"inject","z":"7b4467ef.fde5a8","name":"Start Flow","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"","x":180,"y":200,"wires":[["3d655d83.8daff2"]]},{"id":"3d655d83.8daff2","type":"function","z":"7b4467ef.fde5a8","name":"Initialize","func":"\n// Define runtime1 (4 seconds)\nmsg.runtime1 = 4*1000;\n\n// Define runtime2 (2 seconds)\nmsg.runtime2 = 2*1000;\n\n// Define runtime3 (10 seconds)\nmsg.runtime3 = 10*1000;\n\n// Define runtime4 (6 seconds)\nmsg.runtime4 = 6*1000;\n\n\n// Next to be activated is number 1\nmsg.next = 1;\n\n\nreturn msg;","outputs":1,"noerr":0,"x":340,"y":200,"wires":[["d1640e93.e60bc"]]},{"id":"6c8a9344.dc08ec","type":"delay","z":"7b4467ef.fde5a8","name":"","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":520,"y":280,"wires":[["d1640e93.e60bc","8f5d3dbd.d659e"]]},{"id":"8f5d3dbd.d659e","type":"debug","z":"7b4467ef.fde5a8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":750,"y":280,"wires":[]}]

```

---

<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: [1 June 2019 00:16 UTC](https://discourse.nodered.org/t/trigger-node-help-please/11728/10 "2019-06-01T00:16:43Z")

</div>

I'll look soon.

The _idea_ is that an event happens. Say: Sunset.  
The _flow_ sends a message.  
Then after a given time, a new message is sent.  
After that time again, another message is sent.  
That goes on until I am done.  
When done, an "OFF" message is sent.

The times between the messages is what I want to adjust. It will usually be the same between all the messages.

So having one point where I can edit it is handy and makes it easier if/when I want to change it.

Thanks again for the replies.

I'll get back to you on the latest bit.

This is my latest effort:

```auto
[{"id":"57d90848.942d68","type":"inject","z":"6c223db0.773914","name":"Start Flow","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":"","x":140,"y":120,"wires":[["7fea713a.2a3aa"]]},{"id":"7fea713a.2a3aa","type":"function","z":"6c223db0.773914","name":"Initialize","func":"var interval = 3 * 1000;\n// Define runtime1\nmsg.runtime1 = interval;\n\n// Define runtime2\nmsg.runtime2 = interval;\n\n// Define runtime3\nmsg.runtime3 = interval;\n\n// Define runtime4\nmsg.runtime4 = interval;\n\n// Define runtime5\nmsg.runtime5 = interval;\n\n// Next to be activated is number 1\nmsg.next = 1;\n\nreturn msg;","outputs":1,"noerr":0,"x":300,"y":120,"wires":[["c5192ec4.39a838"]]},{"id":"c5192ec4.39a838","type":"function","z":"6c223db0.773914","name":"Cycle next fan","func":"switch (msg.next) {\n \n case 1:\n msg.delay = msg.runtime1;\n msg.payload = 1; \n msg.next = 2;\n break;\n case 2:\n msg.delay = msg.runtime2;\n msg.payload = 2;\n msg.next = 3;\n break; \n case 3:\n msg.delay = msg.runtime3;\n msg.payload = 3;\n msg.next = 4;\n break; \n \n case 4:\n msg.delay = msg.runtime4;\n msg.payload = 4;\n msg.next = 5;\n break; \n case 5:\n msg.delay = msg.runtime4;\n msg.payload = 5;\n msg.next = 1;\n break; \n\n}\n\n return msg;","outputs":1,"noerr":0,"x":500,"y":120,"wires":[["b40c043.9cbd778","3846424f.31e166","6aa67fb0.e1aca"]]},{"id":"a20bf21d.c17ac8","type":"change","z":"6c223db0.773914","name":"off","rules":[{"t":"set","p":"payload","pt":"msg","to":"OFF","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":220,"wires":[["6aa67fb0.e1aca","b40c043.9cbd778"]]},{"id":"3846424f.31e166","type":"switch","z":"6c223db0.773914","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"4","vt":"num"},{"t":"else"}],"checkall":"true","repair":false,"outputs":2,"x":230,"y":280,"wires":[["7ce8975b.74c168","a20bf21d.c17ac8"],["d64d6ce1.b96f8"]]},{"id":"7ce8975b.74c168","type":"change","z":"6c223db0.773914","name":"stop","rules":[{"t":"set","p":"reset","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":260,"wires":[["d64d6ce1.b96f8"]]},{"id":"d64d6ce1.b96f8","type":"delay","z":"6c223db0.773914","name":"","pauseType":"delayv","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":600,"y":280,"wires":[["c5192ec4.39a838"]]},{"id":"6aa67fb0.e1aca","type":"debug","z":"6c223db0.773914","name":"","active":false,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","x":700,"y":100,"wires":[]}]

```

---

<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: [1 June 2019 00:21 UTC](https://discourse.nodered.org/t/trigger-node-help-please/11728/11 "2019-06-01T00:21:18Z")

</div>

Thanks for that idea! I didn't think of doing it that way with the `reset` function/command.

```auto
    case 5:
        msg.reset = true;
        break;    

```

But.....

Don't worry. I'll nut it out.
