Switch node with HEX input


I am new to NodeRED and I am trying to use the switcher node to filter a HEX code coming from a TCP in node

I receive this HEX 0x1c,0x64,0xa,0x0,0x0,0x0,0xff,0x77 I'd like to split the code up in to 8
separate numbers, so I can react on each of the numbers.

so the switch should work like this.

Hi - the switch node is generally for comparisons, not in the way you are thinking.
You have asked it to match the input to a long string - "if no.0 ...." which of course it won't match.
Realistically for multiple matches in a single go you are probably better off using a function node a small piece of javascript.


Can you help me setting up the function node,

How about using the switch like this, but i cant get it working

I am not sure why you are using the Switcher node, You can use the function node to access each of the elements in your buffer array. For example, replace the Switcher node with a function node and add the following:

if (msg.payload[0] == 0x1c && msg.payload[1] == 0x64)
return msg;

This will filter the messages if I understood what you're trying to do.

1 Like


if i then make two outputs, so i one condition is met go to output 1 and if another is met output 2

if (msg.payload[0] == 0x1c && msg.payload[1] == 0x64)
return msg; //Output 1
if (msg.payload[0] == 0x1c && msg.payload[1] == 0x63)
return msg; //Output 2

You can do it with switches if prepared to calculate the numbers in decimal


For multiple outputs from a function node see the docs
and increase the number of outputs to 2 (or whatever you need)

Great thanks