I'n trying to separate one flow depending if one property is included in a set of values or in other. By now it only has two options (two different sets) but today may have more.
I'm trying to acomplish this in a function node. I would prefer it in a split module for optimization, but still don't have the skills.
Anyways none of the JS methods I know work there. This is the function:
const sensors = [1,4,5,6,7,8,9,10,11];
const actuators = [2,3];
//if (sensors.includes({msg.subType})){ // Doesn't work.
if ($.inArray({msg.subType},sensors) > -1) // Also doesn't work
return msg, null;
else if ($.inArray({msg.subType},actuators) > -1) // Also doesn't work
return null, msg;
return null,null;
I would thank some help from a more experienced node-red user.