Array changes after a time

I'm reading a power consumption device with 2 clamps for solar production and my power consumption.
I have good readings and the problem is a array problem. I would like to subtract my Consumption minus solar production.

I have made a join node that gives me an output with 2 arrays (screenshot)
Then I used the node node-red-contrib-calc and there I made a subtraction.

My 2 arrays are called in debug node 0 and 1

So it needs to subtract ARRAY 0 from ARRAY 1 and here is the problem. Sometimes its ok and sometimes it switches ARRAY 1 first and then ARRAY 0 so my result is different.

Is there a way to get array0 always first?

In my dashboard screenshot at that moment it was ok. And when you see the chart you see it switched.

I hope I'm clear...

How have you configured the Join node? If you set it to generate key/value pairs using the topic as the key, and make sure the two incoming messages have different topics, then you will know which one is which.

I used ANY ARRAY

1 Like

Have you tried my suggestion to use key/value pairs instead?