# AND logic not working with localhost inputs

**URL:** <https://discourse.nodered.org/t/and-logic-not-working-with-localhost-inputs/65152>\
**Category:** General\
**Tags:** function-node\
**Created:** [15 July 2022 17:02 UTC](https://discourse.nodered.org/t/and-logic-not-working-with-localhost-inputs/65152 "2022-07-15T17:02:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![hectorbach2](https://avatars.discourse-cdn.com/v4/letter/h/43a26b/32.png) [@hectorbach2](https://discourse.nodered.org/u/hectorbach2)\
**Post date:** [15 July 2022 17:02 UTC](https://discourse.nodered.org/t/and-logic-not-working-with-localhost-inputs/65152/1 "2022-07-15T17:02:45Z")

</div>

I'm a newb on this programming people and need help, Im using AND logic with local inputs but it is not working however when use ultimate inject the AND logic works fine, can some one watch what do I need to change? what I noted is the ultimate inject has a topic but the localhost input.  
Please help  
Thanks  
Hector

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [15 July 2022 17:13 UTC](https://discourse.nodered.org/t/and-logic-not-working-with-localhost-inputs/65152/2 "2022-07-15T17:13:36Z")

</div>

Not enough info - but I suspect your messages are coming at separate times.

A key peice of knowledge about node red is that multiple messages NEVER travel (or arrive) at the same time.

If you have separate messages that you want to compare, the payload from both messages need to be joined into one message.

See [this article in the cookbook](https://cookbook.nodered.org/basic/join-streams) for an example of how to join messages into one object.

* * *

> [@hectorbach2](#):
>
> I'm a newb on this programming people and need help

I recommend watching this playlist: [Node-RED Essentials](https://www.youtube.com/playlist?list=PLyNBB9VCLmo1hyO-4fIZ08gqFcXBkHy-6). The videos are done by the developers of node-red. They're nice & short and to the point. You will understand a whole lot more in about 1 hour. A small investment for a lot of gain.

---

<div class="post-metadata">

**Author:** ![hectorbach2](https://avatars.discourse-cdn.com/v4/letter/h/43a26b/32.png) [@hectorbach2](https://discourse.nodered.org/u/hectorbach2)\
**Post date:** [15 July 2022 17:45 UTC](https://discourse.nodered.org/t/and-logic-not-working-with-localhost-inputs/65152/3 "2022-07-15T17:45:06Z")

</div>

appreciate your quick response, thanks

---

<div class="post-metadata">

**Author:** ![hectorbach2](https://avatars.discourse-cdn.com/v4/letter/h/43a26b/32.png) [@hectorbach2](https://discourse.nodered.org/u/hectorbach2)\
**Post date:** [27 July 2022 19:01 UTC](https://discourse.nodered.org/t/and-logic-not-working-with-localhost-inputs/65152/4 "2022-07-27T19:01:56Z")

</div>

well, people I'm back to ask for help, after a week trying to understand context and variables context still have a question, I have been trying to setup an input sensor which pull a signal from groov epic, true/false , 1/0, and assign the name to this input but got the same mistake or step, when the name is assign to this input or variable, and try to use a boolean feature, it doesn't recognize the kind of input, it meant, i use a function to request if the input x == true but the payload is all the time like x but the true, can somebody just guide me and help on this trouble..!  
Thanks

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [27 July 2022 20:09 UTC](https://discourse.nodered.org/t/and-logic-not-working-with-localhost-inputs/65152/5 "2022-07-27T20:09:39Z")

</div>

Let's atart with the basics

1. what device are you runnning NR on?
2. what verswion of NR and Node.js are you running (you can get this from the startup log)
3. what extra nodes (node-red-contrib-???) are you using oin your flow?
4. please export your flow and attach it to a reply
5. Give a step by step description of what you are trying to do.

Frankly I do not understand what you are trying to describe. or example:

> [@hectorbach2](#):
>
> pull a signal from groov epic, true/false , 1/0,

is the device returning a true/false or a 1/0? The easy way to find out is attach a `debug` node (set to display the complete msg object) to the output of the groove epic node to see what it is actually returning.

> [@hectorbach2](#):
>
> assign the name to this input but got the same mistake or step

again I don't understand what you are saying. This could be because it has to do with a contrib node, but not knowing waht the node is no-one will be able to help.

* * *

Here is how to copy and post a flow:

In order to make code readable and usable it is necessary to surround your code with three backticks (also known as a left quote or backquote `````)

````auto
``` 
   code goes here 
```

````

You can edit and correct your post by clicking the pencil ✏ icon.

See this post for more details - [How to share code or flow json](https://discourse.nodered.org/t/how-to-share-code-or-flow-json/506)

---

<div class="post-metadata">

**Author:** ![hectorbach2](https://avatars.discourse-cdn.com/v4/letter/h/43a26b/32.png) [@hectorbach2](https://discourse.nodered.org/u/hectorbach2)\
**Post date:** [28 July 2022 16:06 UTC](https://discourse.nodered.org/t/and-logic-not-working-with-localhost-inputs/65152/6 "2022-07-28T16:06:32Z")

</div>

Thanks Zeno, appreciate your interest on this thread.. well it should be easy but my brain is making this complicated. Im using a groov Epic, the module input or the debug just shows the channel input and index, that's set , no topic, just the payload = true or false , so I need this input all around the flow and that's why assigning a var name.  
im using a set or change node and change the input (boolean)  
change msg.payload  
search true  
replace with flow var1  
with this code, Im assuming the true or false is change to the flow var1, so with this change Im assuming I can use function like this  
if (var1 == ' true' )  
{ msg.payload = 'true'; }  
else { msg.payload = 'false' ;}  
msg retrun;

please let me know  
thanks  
Hector

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [28 July 2022 16:43 UTC](https://discourse.nodered.org/t/and-logic-not-working-with-localhost-inputs/65152/7 "2022-07-28T16:43:02Z")

</div>

Hi Hector, just incase you are mixing `true` which is a boolean and `'true'` which is a string.  
so `if (var1 =='true')` should be `if(var1 === true)`

---

<div class="post-metadata">

**Author:** ![hectorbach2](https://avatars.discourse-cdn.com/v4/letter/h/43a26b/32.png) [@hectorbach2](https://discourse.nodered.org/u/hectorbach2)\
**Post date:** [28 July 2022 17:02 UTC](https://discourse.nodered.org/t/and-logic-not-working-with-localhost-inputs/65152/8 "2022-07-28T17:02:27Z")

</div>

really ... omg, thanks a lot E1

---

<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:** [26 September 2022 17:03 UTC](https://discourse.nodered.org/t/and-logic-not-working-with-localhost-inputs/65152/9 "2022-09-26T17:03:00Z")

</div>

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