There is not a simple AND gate node perhaps because in flow based programming values from an earlier message do not hang around until you want to use them. They are not variables.
There is no Java involved. While nodes may be written in Javascript (a very different language) you do not need to know Javascript to use Node-red, any more than you need to understand C to use the Bash shell.
I will try and explain my suggested flow step by step.
We start with a msg which contains msg.payload = { "A": true, "B": false} One message has both of the elements that we want to AND.
And you have been told many many times that there is a node that does what you want - the Ultimate boolean node - however you seem to be continually ignoring this and saying how amazed you are that there is not a simple node
You have two choices if you want to manage multiple incoming messages and do something with them - either use the Join node to turn them into a single message with an identifying property for each message or use something like the Ultimate boolean node and send your messages to it with different topics as part of the message
Thank you for the reply. I do not know/understand how to separate the two incoming message so a Logical And can be created. Have looked at Node-red videos. None that I have found so far explain to me how this is done. Happy to learn but am a newbe. Node-red does a great job establishing communication. That was easy. Having more trouble figuring out how data is handled. It does not work like other system that I have used.
When it comes to Node-red / Java question I misunderstood the nature of the scripting in the programming blocks. Can you aim me at training on how these blocks function?
Craigcurtin: Thanks for your reply. Regret if I am being annoying. That is not the intention. There is a big gap in my understanding of Node-red. My background is in building / lighting controls and electrical power monitoring. Devices / Software in these environments have logical block for the functions I need. I apologize for my ignorance on how these are handled in Node-red. No offence was intended.
The mentioned boolean-logic-ultimate does what you need.
The concept that you need to keep in mind is that an incoming message (ie. payload) has a lifecycle, it lives on its own, it is not aware of other messages, nor are the nodes it passes through - unless they have been created/programmed to handle those requirements.
The join node is one of them, the boolean logic ultimate node is another. Another way is to use "context" to store messages, so that you can compare/combine etc.
bakman2: Thanks for the information. My background is decades as a field technician with building / light control as well as BASIC going back to TI 99/4A, Coleco Adam and Timex Sinclair. Newer programming environments are causing me struggle. I am a child in these modernish ways, so baby steps. There are many newer concepts that are foreign.
Node-red does such a good job with reading data from devices. That was easy to figure out. The rest will take time. Would hope we could keep a friendly dialog for newbes like me.
No need to apologize. Node-RED is not newer, just different. Those of us familiar with programmable logic tend to think in terms of states. The inputs to a logic block represent a state, and the output(s) define a resultant state. This is not how flow-based programming works, and there is bound to be a period of adjustment. By the way, trying to reproduce the patterns of one approach in the other is generally not a good idea. It's better to develop a style that is natural to the environment.
Which do you really want - a script (code based) solution or a low/no-code solution?
People have offered you multiple no-code solutions but you give no indication of having tested them.
Instead you keep hinting that you want a script based solution.
Ok then here is a function node which you can pass two messages sequentially into and if both are true it will return true.
As @drmibell has said, when you adopt a new language you are much wiser to work with the language's strengths than trying to force it to work the way you expect.
Therefore I strongly urge you not to use this function. It is horrible, horrible code for Node-red.
Instead try each of the low/no-code suggestions given by the people who are trying to help you. Let us know how you get on with them?
I presume you mean two nodes rather than blocks. If so then then they are already separate so there is no need to separate them. Just add a change node to the output of each node and in there set the topics to different values "A" and "B" for example. Then feed them into the boolean node.
Edit: unless they already have different topics, in which case you don't need the change nodes.
Regret I called Nodes, Blocks. In many PLC programs Node like objects have been called Blocks. Did find Bool Nodes. It works as expected when true / false used in simulated Inject flow but not in live data flow. Program is attached.
Would rather use Nodes. Showing structured text as examples. Did find Bool Nodes. It works as expected when true / false used in simulated Inject flow but not in live data flow. Program is attached.
Hope someone can find what I am missing.
Regret any frustration my posts cause. Did find Bool Nodes. It works as expected when true / false used in simulated Inject flow but not in live data flow. Program is attached.
Hope someone can find what I am missing.
The terminology used in node-red of "nodes" and "wires" is quite common in flow-based programming. They also relate directly to "vertices" and "edges" in Graph theory.
Many thanks for the reply. Regret that I am not seeing this. Switch output is working. This goes to filter and both examples are putting out true or false results before going to And block.
Just to avoid confusion and unnecessary downloads, can you confirm that the 5 copies you have posted of Hans_Bool_Example.json are all the same file?
Switch output is working. This goes to filter and both examples are putting out true or false results before going to And block.
Can you post actual examples of the data coming out of your two filter nodes in the flow which doesn't work, together with the output of the boolean logic node?