# If 1 = true -\> check if 2 = True -\> if both true = True , Else = False

**URL:** <https://discourse.nodered.org/t/if-1-true-check-if-2-true-if-both-true-true-else-false/54359>\
**Category:** General\
**Created:** [26 November 2021 22:27 UTC](https://discourse.nodered.org/t/if-1-true-check-if-2-true-if-both-true-true-else-false/54359 "2021-11-26T22:27:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![LostiLama](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lostilama/32/42930_2.png) [@LostiLama](https://discourse.nodered.org/u/LostiLama)\
**Post date:** [26 November 2021 22:27 UTC](https://discourse.nodered.org/t/if-1-true-check-if-2-true-if-both-true-true-else-false/54359/1 "2021-11-26T22:27:50Z")

</div>

Hello i m want a simple if else sircet but instad of switches with buttons  
so i select number 2 so Button 2 is true than thats saved for 5 second and when in this time a aktivations switch is pressed its true. but im not sure how to do this.

---

<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:** [26 November 2021 23:45 UTC](https://discourse.nodered.org/t/if-1-true-check-if-2-true-if-both-true-true-else-false/54359/2 "2021-11-26T23:45:23Z")

</div>

Hi @LostiLama

I am trying to understand what you mean, but can't.

What are the inputs - to be clear?  
Node-red buttons or physical buttons via GPIO?

How many buttons?

Idea:  
Although I believe **time** is also in the formula, try to draw a table of what you want to happen.

I can't show an example just now as formatting text is not allowed here.  
I'll go away and make a picture and post it soon.

![example2](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/8/2860ae2e29ced71fbe313046b7d7e674496895e6.png)

Grey = off  
Green = on  
yellow = don't care

1,2,3 inputs.  
0 output.

---

<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:** [27 November 2021 00:13 UTC](https://discourse.nodered.org/t/if-1-true-check-if-2-true-if-both-true-true-else-false/54359/3 "2021-11-27T00:13:10Z")

</div>

This is a bit of code I made.

I don't really know what you want, but it does what I think you mean.

Press either of the `inject` nodes.  
Press the other one within `5` seconds and you get an output.  
If you wait more than `5` seconds, nothing happens.

Not perfect - I'm sure - and you need a _foreign_ node:  
`node-red-contrib-queue-gate`

```auto
[{"id":"435f958cf7838596","type":"trigger","z":"65c9b63cb09879a0","name":"","op1":"","op2":"0","op1type":"nul","op2type":"str","duration":"5","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":470,"y":2550,"wires":[["d438eb4f1721d421"]]},{"id":"70fbcc90902efe7c","type":"inject","z":"65c9b63cb09879a0","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"A","payloadType":"str","x":280,"y":2550,"wires":[["435f958cf7838596","5a0977f7980f71c5","c211e18e54e5ffd7"]]},{"id":"12e5a75dfcd214da","type":"inject","z":"65c9b63cb09879a0","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"B","payloadType":"str","x":280,"y":2690,"wires":[["192d5ee3605f0aeb","e41b5aa7c73cccb8","a06e461907a508b7"]]},{"id":"192d5ee3605f0aeb","type":"trigger","z":"65c9b63cb09879a0","name":"","op1":"","op2":"0","op1type":"nul","op2type":"str","duration":"5","extend":false,"overrideDelay":false,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":470,"y":2690,"wires":[["c03615454637527a"]]},{"id":"5a0977f7980f71c5","type":"q-gate","z":"65c9b63cb09879a0","name":"","controlTopic":"control","defaultState":"queueing","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","peekCmd":"peek","dropCmd":"drop","statusCmd":"status","maxQueueLength":"1","keepNewest":false,"qToggle":false,"persist":false,"storeName":"memory","x":610,"y":2490,"wires":[["c8fb069fb3e702eb"]]},{"id":"e41b5aa7c73cccb8","type":"q-gate","z":"65c9b63cb09879a0","name":"","controlTopic":"control","defaultState":"queueing","openCmd":"open","closeCmd":"close","toggleCmd":"toggle","queueCmd":"queue","defaultCmd":"default","triggerCmd":"trigger","flushCmd":"flush","resetCmd":"reset","peekCmd":"peek","dropCmd":"drop","statusCmd":"status","maxQueueLength":"1","keepNewest":false,"qToggle":false,"persist":false,"storeName":"memory","x":610,"y":2640,"wires":[["c8fb069fb3e702eb"]]},{"id":"d438eb4f1721d421","type":"change","z":"65c9b63cb09879a0","name":"Reset","rules":[{"t":"set","p":"payload","pt":"msg","to":"reset","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":2550,"wires":[["5a0977f7980f71c5","e41b5aa7c73cccb8"]]},{"id":"c211e18e54e5ffd7","type":"change","z":"65c9b63cb09879a0","name":"Trigger","rules":[{"t":"set","p":"payload","pt":"msg","to":"trigger","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":2590,"wires":[["e41b5aa7c73cccb8"]]},{"id":"c03615454637527a","type":"change","z":"65c9b63cb09879a0","name":"Reset","rules":[{"t":"set","p":"payload","pt":"msg","to":"reset","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":610,"y":2690,"wires":[["e41b5aa7c73cccb8","5a0977f7980f71c5"]]},{"id":"a06e461907a508b7","type":"change","z":"65c9b63cb09879a0","name":"Trigger","rules":[{"t":"set","p":"payload","pt":"msg","to":"trigger","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"control","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":2730,"wires":[["5a0977f7980f71c5"]]},{"id":"c8fb069fb3e702eb","type":"debug","z":"65c9b63cb09879a0","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":830,"y":2600,"wires":[]}]

```

Hope that helps.

---

<div class="post-metadata">

**Author:** ![LostiLama](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/lostilama/32/42930_2.png) [@LostiLama](https://discourse.nodered.org/u/LostiLama)\
**Post date:** [27 November 2021 09:39 UTC](https://discourse.nodered.org/t/if-1-true-check-if-2-true-if-both-true-true-else-false/54359/4 "2021-11-27T09:39:16Z")

</div>

Je this is the right Thing i needed 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:** [27 November 2021 20:20 UTC](https://discourse.nodered.org/t/if-1-true-check-if-2-true-if-both-true-true-else-false/54359/5 "2021-11-27T20:20:30Z")

</div>

If you mean the code, it may be better to mark that post as the solution.

---

<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:** [11 December 2021 20:21 UTC](https://discourse.nodered.org/t/if-1-true-check-if-2-true-if-both-true-true-else-false/54359/6 "2021-12-11T20:21:08Z")

</div>

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