Multiple JSON message into one Function Node

I'm sure this is really simple; I'm new to all this.

I had a string from a link node and I have re-defined as a JSON message through a function; with

msg.payload = {
"OPC_Tag": msg.topic,
"Value": msg.payload
}
return msg;
This is the output;

20/04/2022, 08:21:54node: e41071c52edf8130
ns=3;s=OPC_MAIN_SUPPLY_FLOW_FT230 : msg.payload : Object
object
OPC_Tag: "ns=3;s=OPC_MAIN_SUPPLY_FLOW_FT230"
Value: "262.80"

I have multiple messages going into this node; and then into another function where I want to split the values out so I can do an if this equals that etc. So some how I need to have the message come into the second function node that is specific so I can tag the variables specific to the message.

Probably a bad explanation.....sure this simple.
Cheers,
Ant

That looks all ok, with the possible difficulty that your value is a string.

I really can't understand what you are asking here. Is it that you want to compare data from one message with data from another?

Perhaps you can give us more examples of the data you have and the result you want to get?

Apologies it is probably the worst explanation possiable.

So i have three nodes outputting numbers (msg.payload) each with a different topic; ie the name of the variable.

I want to bring them into a single function block and do an if 1 = 2 < 3 (for example); How do I set the value into a variable, that is specific to a topic; so as the message comes in they are all msg.payload; but I need to split them up and place in the correct variable.

I've only ever had one variable or one JSON string come into the function block; not multipe messages.

Cheers,
Ant

You can join the 3 messages with a join node set to manual and key value object, you use the 3 different topics to create a payload. Try it and see what you get. You can set the join on a count or a time out, or you can send msg.complete to output the new combined object.
There is a example in the cookbook , and many in this forum.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.