Wrong Value in Array

Hello my dear friends, I need to create a small system where three input values of the power phase need to be summed. For this, I am using the "join" node to create an array. But the problem now is that the values from the array do not match the individual values in the power phase nodes. Can someone show me how to create a simple array with three values (coming from different nodes). Or can someone help me sum three values from three different nodes? I WOULD greatly appreciate any advice.


And as u can see at this picture below it does not make any sense.

and again i would really appreciate any help i can get from you guys.

My guess is that the 'phase 2' node is sending a msg, then the 'phase 3' node is sending 2 msg's and since the join node is looking for three messages is sends those three messages.

You could look at the sidebar debug and look at the timestamps for the messages to check this out.

Let me think about how you could only allow one from each to get thru....

What would you want to occur it phase 1 sent a message with a value and then phase 2 sends two messages one with a value of 100 and the second with 200...which value would you want?

First of all thx for your fast respond :slight_smile: So your first guess sound pretty good i think. but yea the question is how can i "collect" three values (from Phase1,2 and 3 ) create an array and send it to the next node. and not mixing it up with different values if u know what i mean.

well i dont exactlly understand what u mean with this but as i said. the three values from the same timestamp sould be joined into one array. :confused:

At the end it sould be something like this (There are also the values from the same time (i guess) ) ....

I suggest using the Join node in key/value mode, and make sure the three inputs have separate topics. Then you will be guaranteed to get all three inputs. Then you can organise the data however you want.

1 Like

i will try it and let you guys know if it helped. thank you in advice

I didn't see that in the previous pots but I was going to suggest the same thing as @Colin did, add a unique topic to each msg and then you will have an object.

However if you want ALL the data in each msg you will have to change things so that msg.payload is an object. This could be done in a change node before getting to the join node.

Here is a simple example:

[{"id":"16d736db0bdee8b8","type":"join","z":"c40339e97a7d4c88","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"3","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"num","reduceFixup":"","x":690,"y":200,"wires":[["39ef0430c89ad973"]]},{"id":"66f9975e11d1d49d","type":"inject","z":"c40339e97a7d4c88","name":"1","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"time","v":"","vt":"date"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"one","payload":"300","payloadType":"num","x":170,"y":120,"wires":[["a9c72fc019615889"]]},{"id":"d6db8c058923a2ae","type":"inject","z":"c40339e97a7d4c88","name":"2a","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"time","v":"","vt":"date"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"two","payload":"250","payloadType":"num","x":170,"y":180,"wires":[["341fd1f9b45f27e4"]]},{"id":"e0ee180a5ce0df67","type":"inject","z":"c40339e97a7d4c88","name":"2b","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"time","v":"","vt":"date"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"two","payload":"700","payloadType":"num","x":170,"y":220,"wires":[["341fd1f9b45f27e4"]]},{"id":"83de4e5df156326b","type":"inject","z":"c40339e97a7d4c88","name":"3","props":[{"p":"payload"},{"p":"topic","vt":"str"},{"p":"time","v":"","vt":"date"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"three","payload":"16","payloadType":"num","x":170,"y":320,"wires":[["43c69fe65f52a086"]]},{"id":"39ef0430c89ad973","type":"debug","z":"c40339e97a7d4c88","name":"debug 3","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":960,"y":180,"wires":[]},{"id":"a9c72fc019615889","type":"change","z":"c40339e97a7d4c88","name":"","rules":[{"t":"set","p":"oldpayload","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"move","p":"oldpayload","pt":"msg","to":"payload.payload","tot":"msg"},{"t":"set","p":"payload.time","pt":"msg","to":"time","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":120,"wires":[["16d736db0bdee8b8"]]},{"id":"341fd1f9b45f27e4","type":"change","z":"c40339e97a7d4c88","name":"","rules":[{"t":"set","p":"oldpayload","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"move","p":"oldpayload","pt":"msg","to":"payload.payload","tot":"msg"},{"t":"set","p":"payload.time","pt":"msg","to":"time","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":200,"wires":[["16d736db0bdee8b8"]]},{"id":"43c69fe65f52a086","type":"change","z":"c40339e97a7d4c88","name":"","rules":[{"t":"set","p":"oldpayload","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"payload","pt":"msg","to":"{}","tot":"json"},{"t":"move","p":"oldpayload","pt":"msg","to":"payload.payload","tot":"msg"},{"t":"set","p":"payload.time","pt":"msg","to":"time","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":320,"wires":[["16d736db0bdee8b8"]]}]
1 Like

So my dear friends it worked ( for now heheh) so i tried to add topics and send the whole object to the next node and yeaaa now it works. its syncron to the other data and it is doing what i want it to do :smiley: I wish you all a nice day and if somebody ever have the same problem/issue like me here my way:

First i added to every phase a topic and a source with the three functions (func1,2,3) (picture 1) then i joind it with key/value option and at the sumup i used this code:

// Initialize the total sum to 0
let totalSum = 0;

// Loop through the object properties
for (const prop in msg.payload) {
  if (msg.payload.hasOwnProperty(prop) && msg.payload[prop].hasOwnProperty('payload') && msg.payload[prop].payload.hasOwnProperty('value')) {
    // Add the value of each phase to the total sum
    totalSum += msg.payload[prop].payload.value;

// Create a new message with the total sum
msg.payload = totalSum;

// Optionally, you can set a new topic for the message if desired
msg.topic = "Total Power Sum";

// Return the new message
return msg;

There the pictures: '



Well thats is from my side :slight_smile: cya

1 Like

Being pedantic, you are not creating a new message, you are just setting the payload on the original message. There is usually no need to create a new message.

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