Splitting Values

Hello All.
I’m using a Node-Red library for receiving data from a SIemens PLC.
When receiving the items - i get them from msg.payload in format { variable1, variable2}
How do i split theese into multiple values - so i make a function that can take “Variable1” and put into a HACS Helper?

I tried “Split”, “JSON” and “Function” in Node-Red - but can’t get any of them working.

I can easily get the values when inserting a Debug Node - but always “connected” and not “Splitted”

In a function node.

const regex = /{([^}]*)}/;
const match = msg.payload.match(regex);

msg.payload = match[1].split(",").map(i => i.trim());

return msg;

Yes about the same i came up to - but how to split the result in multiple outputs?
So the Function will have multiple outputs? Or should i hardcode the HA Helper variable inside the Function?

This is what you should see right now. You should see a series of different messages. For multiple connection points a switch node would allow you to break up those messages to discrete outputs.

To have multiple discrete outputs on a function, the setup tab in the function node will allow you to add outputs. Then each message needs to be defined in the function.

https://nodered.org/docs/user-guide/writing-functions#multiple-messages

Awesome - that worked - Thanks :slight_smile: