# Interval if state

**URL:** <https://discourse.nodered.org/t/interval-if-state/43149>\
**Category:** General\
**Created:** [24 March 2021 21:46 UTC](https://discourse.nodered.org/t/interval-if-state/43149 "2021-03-24T21:46:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Napster](https://avatars.discourse-cdn.com/v4/letter/n/65b543/32.png) [@Napster](https://discourse.nodered.org/u/Napster)\
**Post date:** [24 March 2021 21:46 UTC](https://discourse.nodered.org/t/interval-if-state/43149/1 "2021-03-24T21:46:32Z")

</div>

Hi,

I need a inject node with a interval every 10 sec, this should only need to work when payload is 0

kind regards

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [24 March 2021 22:00 UTC](https://discourse.nodered.org/t/interval-if-state/43149/2 "2021-03-24T22:00:56Z")

</div>

There are many approaches to tackle this but one is to use a Trigger node instead since the Inject node doesnt accept an input.

Test flow :

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/b/abef445fa95d886e82eb15d66c9f209872af3aec.png)

```auto
[{"id":"a47e0c17.5bf2b8","type":"trigger","z":"981a2a72.4329f","name":"","op1":"","op2":"0","op1type":"pay","op2type":"str","duration":"-10","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":590,"y":1260,"wires":[["ca255ae1.5f2d88"]]},{"id":"6291a8b6.587d78","type":"inject","z":"981a2a72.4329f","name":"0","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"0","payloadType":"num","x":250,"y":1240,"wires":[["a12ef40f.d79278"]]},{"id":"75073b67.090034","type":"inject","z":"981a2a72.4329f","name":"1","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"1","payloadType":"num","x":250,"y":1300,"wires":[["a12ef40f.d79278"]]},{"id":"a12ef40f.d79278","type":"function","z":"981a2a72.4329f","name":"","func":"if (msg.payload == 0) {\n return msg\n}\nelse {\n msg.reset = true\n return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":400,"y":1260,"wires":[["a47e0c17.5bf2b8"]]},{"id":"ca255ae1.5f2d88","type":"debug","z":"981a2a72.4329f","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":800,"y":1260,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![Napster](https://avatars.discourse-cdn.com/v4/letter/n/65b543/32.png) [@Napster](https://discourse.nodered.org/u/Napster)\
**Post date:** [25 March 2021 11:24 UTC](https://discourse.nodered.org/t/interval-if-state/43149/3 "2021-03-25T11:24:13Z")

</div>

Thanks a lot !!

---

<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:** [8 April 2021 11:24 UTC](https://discourse.nodered.org/t/interval-if-state/43149/4 "2021-04-08T11:24:56Z")

</div>

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