Crate an ARRAY in Function node to send it to G.Sheet Node

Dear All,
I'm trying to solve thi issue but searching in the forum Topic, I'm not able to find a solution.

I want to add commands to this "function node" to make an UNIQUE ARRAY that contains the 4 values PZEM*, to send to output 5 to send to google sheets.**

(My G.Sheets Node works properly, forcing the array with an "Injection node"that send an array, the sheet is updated)

So I neeed to make an only one ARRAY, sended once, with the 4 different PZEM varables created in this Fuunction node.

The ARRAY to be sended by G.Sheet Node, must be siple as : ["aaaa","bbb","ccc","ddd"]

Here the Function Node where i need to make and add the output nr.5 "Datalogger":

let PEZMPower={}, PEZMYesterday={}, PEZMToday={}, PEZMTotal={}, X={}, Datalogger={};

PEZMPower.payload = msg.payload['ENERGY'].Power;
PEZMToday.payload = msg.payload['ENERGY'].Today;
PEZMYesterday.payload = msg.payload['ENERGY'].Yesterday;
PEZMTotal.payload = msg.payload['ENERGY'].Total;

return [ PEZMPower, PEZMToday, PEZMYesterday, PEZMTotal, Datalogger ];

Thanks in advance.

Would this work for you?

let PEZMPower={}, PEZMYesterday={}, PEZMToday={}, PEZMTotal={}, X={}, Datalogger={};

PEZMPower.payload = msg.payload['ENERGY'].Power;
PEZMToday.payload = msg.payload['ENERGY'].Today;
PEZMYesterday.payload = msg.payload['ENERGY'].Yesterday;
PEZMTotal.payload = msg.payload['ENERGY'].Total;
Datalogger.payload = [
    msg.payload['ENERGY'].Power,
    msg.payload['ENERGY'].Today,
    msg.payload['ENERGY'].Yesterday,
    msg.payload['ENERGY'].Total
]

return [ PEZMPower, PEZMToday, PEZMYesterday, PEZMTotal, Datalogger ];

Thank you very much... it WORKS, the ARRAY is correct made!!!

but the Gsheet node receive 2 or 3 inoput signal to write!!

I do not know yor set up, so at a guess.
It looks like your mqtt node is outputting the same info twice 30 seconds apart.
You could try setting it to output a string, then pass that through a filter/rbe node, so if output is the same string it will not pass, after the filter node you then can use a json node to convert the string to an JSON object.

Or look to see why the device is sending the data twice.

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