How to make an AND gate graphically

I'm very new with Home Assistant and Node-Red.

I'm searching how to make an AND gate with the graphical representation.

I want to make:

if "we are at home" AND "we are not sleeping" AND "it's dark"
then "turn all lights on"
else "turn all lights off"

With some trial and error I found the following working. But it looks very complicated on screen

How can i make the represention more simple? By using an AND gate?
Something like this

image

Thanks

Have a look at node-red-contrib-bool-gate. There you can configure the AND gate of all three inputs. Make sure the three inputs have different topics so they can be identified in the gate. That will give you a true or false output which may be able to feed direct to the lights, or you may have to convert the true/false to on/off or whatever which you can do in a Change node.

Thanks. It seems that this node is what i need.
But i still have a problem to make it work.

This simple example of "ANDing" twice a value that is TRUE at this moment, should return TRUE and shoud turn the ligt on. But it is not.
What am I doing wrong?

The topics "switch_wij_zijn_thuis" are the same.
This need to be 2 different topics.

What isn't working? Is it the value coming out of the AND node or the value is correct but it doesn't turn the light on?

If it is the value that is coming out of the node that is wrong then add a debug node showing the two messages that are going into the AND node and show us what you see. Did you see my previous comment: Make sure the three inputs have different topics so they can be identified in the gate?

I started with three different topics. But at the end I tried with two same topics

First the debug output of two topics. We are at home is True . We are sleeping is false

image

The debug of the AND gate shows null

What do you mean it shows null? Do you mean it sends a message containing a payload of null?
Show us what you see in the debug nodes for the data going in and the data coming out.

Sorry, I'm very new

First a screenshot of the tet configuration

And now the result of my tests. In test4, only one value is TRUE, the other FALSE. But the light changed like you can see in the debug output

You haven't shown the debug for the failing state with one true and one false. I want to see it in the debug output. You don't need to show the flow again, just the debug outputs.

Indeed.

But it seems that the debug screen shows only the values changing to TRUE and not the values changing to FALSE. What should I do?

But below the input you can see one state FALSE at 14u03 and one state becoming TRUE later at 14u04. Ans also at 14u04, the light changed.

Well if you aren't getting a false output from the Sleeping and At Home nodes then obviously the gate won't know what to do. I don't know those blue nodes at all, are they supposed to send out true and false? Perhaps false comes on the other output. Have a look at the docs for that node.

Thanks for you time.
I will check your tip: "Perhaps false comes on the other output"

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