Hi.
I am trying to get data from two nodes to debug nodes, by a function.
If I add a debug node to the two nodes (zigbee nodes) I get this data.


I am then trying to get the payload data by a function and if the:
contact is "false" then it need to send the payload data to one debug node
occupancy is "true" it need to send the payload data to another debug node

But I get no data from the function.
My function code is (on message):
node.status({fill:"green",shape:"ring",text:"done"});
var contact = msg.payload.contact;
var occupancy = msg.payload.occupancy;
if (contact == "false"){
return [msg,null];
}
if (occupancy == "true"){
return [msg,null];
}
contact is boolean not a string.
so this should work.
if (contact == false){
return [msg,null];
}
NOTE: you could use a simple switch node to do this.
Hi @Steve-Mcl THX.
"the needle in the haystack"
I started with a switch node... but how can i get the switch node to look on both msg.payload.contact;
and msg.payload.occupancy?
You can use 2 switch nodes
sw1 - contact == false OR otherwise
sw2 - occupancy == true or otherwise
or you can do it with e switch node and a JSONata expression

expression: payload.contact = false ? 1 : (payload.occupancy = true ? 2 : 0)
but, the function node is sometimes the best solution.
because the 2nd return needs a different signature...
if (occupancy == true){
//return [msg, null]; //<< output to pin 1
return [null, msg]; //<< output to pin 2
}
Doesn't this work in a switch node.
