# Logic gate doesn't seem to behave logically

**URL:** <https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531>\
**Category:** General\
**Created:** [1 July 2023 22:03 UTC](https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531 "2023-07-01T22:03:25Z")\
**Posts on this page:** 20\
**Page:** 4

<div class="post-metadata">

**Author:** ![usernamepasswordBS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/usernamepasswordbs/32/81035_2.png) [@usernamepasswordBS](https://discourse.nodered.org/u/usernamepasswordBS)\
**Post date:** [8 July 2023 08:48 UTC](https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531/66 "2023-07-08T08:48:33Z")

</div>

So the flow is "live" and the % hit 50, the amps were +20 so it switched one relay on. So far so good. Then it switched another one on even though the % had not reached the threshold of 70%. I guess this is an error in the Compare node (which I edited) or in the operation of the AND which as the screenshot shows, stays "true" sometimes when the inputs do not justify it.  
Any clues would be much appreciated.

---

<div class="post-metadata">

**Author:** ![usernamepasswordBS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/usernamepasswordbs/32/81035_2.png) [@usernamepasswordBS](https://discourse.nodered.org/u/usernamepasswordBS)\
**Post date:** [8 July 2023 08:50 UTC](https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531/67 "2023-07-08T08:50:40Z")

</div>

Ok, I can do that.  
May I ask why you would say that the simple debug outputs on the screenshot show us nothing; are they not accurate then?

---

<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:** [8 July 2023 08:50 UTC](https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531/68 "2023-07-08T08:50:55Z")

</div>

> [@usernamepasswordBS](#):
>
> when I was trying with Ultimate I used the node in that mode.  
> Here is a screenshot of what I am talking about:

That isn't the Boolean Ultimate node, that node has three outputs, and looks like  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/8/b8d12dc0424f84f5a0fbb3c242266c87eb3fe458.png)

---

<div class="post-metadata">

**Author:** ![usernamepasswordBS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/usernamepasswordbs/32/81035_2.png) [@usernamepasswordBS](https://discourse.nodered.org/u/usernamepasswordBS)\
**Post date:** [8 July 2023 08:56 UTC](https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531/69 "2023-07-08T08:56:34Z")

</div>

As I said, I previously tried with Ultimate and that had unexpected results also so I changed to this one. With this logic node that I am using now I have at least got it working partially correctly.

---

<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:** [8 July 2023 08:57 UTC](https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531/70 "2023-07-08T08:57:17Z")

</div>

> [@usernamepasswordBS](#):
>
> why you would say that the simple debug outputs on the screenshot show us nothing

That was an exaggeration, but since the outputs of the Gate node depend also on the topic values and the sequence of messages sent to it, unless you know the topic values and the sequence it is not possible to be sure what is going on. But since your example is not using the Boolean Ultimate node that flow tells us nothing about the operation of the Boolean Ultimate node.

---

<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:** [8 July 2023 08:59 UTC](https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531/71 "2023-07-08T08:59:28Z")

</div>

My advice is to use the Ultimate node. If it is not working for you then show us an example if it not working.

---

<div class="post-metadata">

**Author:** ![usernamepasswordBS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/usernamepasswordbs/32/81035_2.png) [@usernamepasswordBS](https://discourse.nodered.org/u/usernamepasswordBS)\
**Post date:** [8 July 2023 09:00 UTC](https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531/72 "2023-07-08T09:00:50Z")

</div>

OK, I will set that up later and see how it goes.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [8 July 2023 10:04 UTC](https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531/73 "2023-07-08T10:04:57Z")

</div>

Wow, 67 posts and we still don't have a clear idea of the node you are using, the data you are passing to it or the output you are getting. I'm confused.

---

<div class="post-metadata">

**Author:** ![usernamepasswordBS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/usernamepasswordbs/32/81035_2.png) [@usernamepasswordBS](https://discourse.nodered.org/u/usernamepasswordBS)\
**Post date:** [8 July 2023 10:45 UTC](https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531/74 "2023-07-08T10:45:36Z")

</div>

Have you looked at the flows I've posted? It should give you some answers.

---

<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:** [8 July 2023 11:00 UTC](https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531/75 "2023-07-08T11:00:44Z")

</div>

Have you posted what has been asked for several times, which is the debug pane output showing the sequence of messages going to the gate node, and how you have configured it?

---

<div class="post-metadata">

**Author:** ![tree-frog](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tree-frog/32/89303_2.png) [@tree-frog](https://discourse.nodered.org/u/tree-frog)\
**Post date:** [9 July 2023 18:03 UTC](https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531/76 "2023-07-09T18:03:51Z")

</div>

Sorry, for all that if you already know these concepts. It seemed to me that you were saying you got a "True" when you expected a "1".

---

<div class="post-metadata">

**Author:** ![tree-frog](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tree-frog/32/89303_2.png) [@tree-frog](https://discourse.nodered.org/u/tree-frog)\
**Post date:** [9 July 2023 18:52 UTC](https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531/77 "2023-07-09T18:52:48Z")

</div>

OK, It seems that the problem is on "Startup" only? Or is it that you get results at times that you do not expect. When you said in your comment just now ..

> [@usernamepasswordBS](#):
>
> I have found (or at least I think I have) that sometimes the debug nodes are showing a "1" and a "0" on the node input yet the AND output is "true".  
> I think I have got over this but I can't remember exactly how (!) so it seems to be working fine but when my flow restarts ...

Input to what, which node?  
What are the topic names? Per input?  
And, what if you use a "true" or "false" as input vs. the "1" or "0"?  
Do you initialize with any value? "true" or "false". Maybe what your looking at is the initial state before there are any inputs evaluated.

You need to know what inputs are causing what results. So initialization, or states that are not properly named with the proper topic will trip you up. Try to not have any messages inserted that do not have proper topic and payload values.

---

<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:** [9 July 2023 19:07 UTC](https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531/78 "2023-07-09T19:07:23Z")

</div>

I think all of that will be answered when @usernamepasswordBS provides the sequence of input messages that are causing the problem, in the debug pane, as has been requested.

---

<div class="post-metadata">

**Author:** ![tree-frog](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tree-frog/32/89303_2.png) [@tree-frog](https://discourse.nodered.org/u/tree-frog)\
**Post date:** [9 July 2023 19:10 UTC](https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531/79 "2023-07-09T19:10:35Z")

</div>

Ya, I hope he complies.

---

<div class="post-metadata">

**Author:** ![usernamepasswordBS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/usernamepasswordbs/32/81035_2.png) [@usernamepasswordBS](https://discourse.nodered.org/u/usernamepasswordBS)\
**Post date:** [14 July 2023 21:46 UTC](https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531/80 "2023-07-14T21:46:38Z")

</div>

@usernamepasswordBS does not comply!

---

<div class="post-metadata">

**Author:** ![tree-frog](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tree-frog/32/89303_2.png) [@tree-frog](https://discourse.nodered.org/u/tree-frog)\
**Post date:** [14 July 2023 23:17 UTC](https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531/81 "2023-07-14T23:17:21Z")

</div>

Your resistance is futile. You will be assimilated.

---

<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:** [15 July 2023 07:40 UTC](https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531/82 "2023-07-15T07:40:44Z")

</div>

Why do you not provide the information asked for? Do you not want to know why the node did not work for you?

---

<div class="post-metadata">

**Author:** ![usernamepasswordBS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/usernamepasswordbs/32/81035_2.png) [@usernamepasswordBS](https://discourse.nodered.org/u/usernamepasswordBS)\
**Post date:** [15 July 2023 08:38 UTC](https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531/83 "2023-07-15T08:38:12Z")

</div>

🤣 🤣 🤣 👾 👾 👾 🤣 🤣 🤣 (9 characters minimum)

---

<div class="post-metadata">

**Author:** ![tree-frog](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/tree-frog/32/89303_2.png) [@tree-frog](https://discourse.nodered.org/u/tree-frog)\
**Post date:** [22 July 2023 22:04 UTC](https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531/84 "2023-07-22T22:04:39Z")

</div>

@Colin ,  
This person apparently does not want any assistance.

Good Luck @usernamepasswordBS. HA! your handle.

---

<div class="post-metadata">

**Author:** ![usernamepasswordBS](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/usernamepasswordbs/32/81035_2.png) [@usernamepasswordBS](https://discourse.nodered.org/u/usernamepasswordBS)\
**Post date:** [23 July 2023 08:15 UTC](https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531/85 "2023-07-23T08:15:04Z")

</div>

No no, I do want help and I appreciate the help that I've already had from this site particularly Frida who wrote a Function Node for me.

I haven't reposted anything because I'm not sure why it wasn't easy to know which logic node I was using by looking right there in the flow that I posted. I also thought its configuration would be visible but may be I'm wrong.

[Previous page](https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531.md?page=3)

[Next page](https://discourse.nodered.org/t/logic-gate-doesnt-seem-to-behave-logically/79531.md?page=5)
