Hi all, I would like create AND condition with many node input. If all are true then pass to node after.
I'm trying using SWITCH function but i think it is not usefull for this application.
Do you have some suggestions?
many thanks in advance
Hi all, I would like create AND condition with many node input. If all are true then pass to node after.
I'm trying using SWITCH function but i think it is not usefull for this application.
Do you have some suggestions?
many thanks in advance
The first (and most important) thing to understand is that 1 msg
travels down 1 wire at a time. This means messages NEVER arrive from multiple wires to a node at the same time.
This leaves you with the thought - how do I get all messages into a switch/function at once? The answer is to either store them until all are received OR use a join node.
See this article in the cookbook for an example of how to join messages into one object.
Once you have all data in one object, you can then compare the parts
e.g. in a function
if(msg.payload.m1.value === true && msg.payload.m2.value === true && msg.payload.m3.value === true) {
msg.payload = true
} else {
msg.payload = false
}
return msg;
This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.