Issues with udp node. Extra characters are added

Hi folks!

I managed to get input from smart switches and send them via Zigbee2MQTT and Node-RED and OSC / UDP to another app (Cycling '74 Max in my case). You can see how in the attached images.

Now I am trying to control some LED lights in Home Assistant / Node-RED from the other app via OSC / UDP. But I cannot figure out how to separate messages from something like /ha/led01/on and /ha/led02/on to control each individual light

I also tried just using normal messages via UDP set UDP to output a string. And I get a string out from udp in that looks pretty much the same except for an extra comma. But in the debug it says it has some extra 4 index values (in my case 12 instead of 8 for the message /l01/on). If I use an inject node I get 8 index values like I should. And because of this, it is not recognized down the road by other nodes (for example by the change node)

Any idea on how to fix this issues? So firstly how to use OSC to separate the tags. Or how can I get via udp a string with no extra comma and / or without extra 4 index values.

I was thinking as last resort, to extract the extra info from the string but no idea how.

Thank you so much!


There may be non-printable characters in the UDP output.

Could you try to send the output through a function node with the following content:

const input = msg.payload 
msg.payload = input.replace(/[^\x00-\x7F]/g, "");
return msg;

It will keep the ASCII characters

Udp payload is often binary and should be treated as a buffer. If you convert it to a string the default is to use utf8 which may interpret some binary incorrectly.

Do you know how I can convert the buffer to a string so I can use it as a command? I just want it to be recognized by the changes nodes. So for example if I send a string like this /l01/on from the external app, I get the exact same string to send to change it to on to use it as a specific command to a call service node.

Thank you so much!