# Conditional Timing Logic best practice

**URL:** <https://discourse.nodered.org/t/conditional-timing-logic-best-practice/8015>\
**Category:** General\
**Created:** [15 February 2019 15:58 UTC](https://discourse.nodered.org/t/conditional-timing-logic-best-practice/8015 "2019-02-15T15:58:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![RichardU](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/richardu/32/19854_2.png) [@RichardU](https://discourse.nodered.org/u/RichardU)\
**Post date:** [15 February 2019 15:58 UTC](https://discourse.nodered.org/t/conditional-timing-logic-best-practice/8015/1 "2019-02-15T15:58:37Z")

</div>

I'm creating a trigger based on event X. However, I only want to activate the trigger if event Y has not happened in the last, say 5 minutes.

In other words, every time event Y happens, kill my trigger for 5 minutes.

What would be the Node Red best practice to accomplish that?

Thanks, Richard

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [15 February 2019 16:02 UTC](https://discourse.nodered.org/t/conditional-timing-logic-best-practice/8015/2 "2019-02-15T16:02:14Z")

</div>

Hi @RichardU

The Trigger node, or a combination of them, can probably do what you want.

This recipe from the cookbook probably comes close: [https://cookbook.nodered.org/basic/trigger-placeholder](https://cookbook.nodered.org/basic/trigger-placeholder)

---

<div class="post-metadata">

**Author:** ![RichardU](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/richardu/32/19854_2.png) [@RichardU](https://discourse.nodered.org/u/RichardU)\
**Post date:** [16 February 2019 12:53 UTC](https://discourse.nodered.org/t/conditional-timing-logic-best-practice/8015/3 "2019-02-16T12:53:47Z")

</div>

Thanks. I ended up using trigger nodes to send boolean true, followed by boolean false in five minutes. Those flow into a change node which sets a flow variable. I then test that variable using a switch node (which is like an IF statement).  
Cheers, Richard

---

<div class="post-metadata">

**Author:** ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)\
**Post date:** [17 February 2019 20:14 UTC](https://discourse.nodered.org/t/conditional-timing-logic-best-practice/8015/4 "2019-02-17T20:14:19Z")

</div>

> [@RichardU](#):
>
> Those flow into a change node which sets a flow variable. I then test that variable using a switch node

You might be able to replace the `change` and `switch` nodes with a `gate` node (`node-red-contrib-simple-gate`). Just close the gate for five minutes each time the the `trigger` nodes receive event Y.
