Change a value in a message object

Hi

I have the following function as part of my weather station dashboard-

var m = {
"series": ["Rainfall"],
"data":[msg.payload[0] ["sum(RAINFALL)"]],
"labels":["Todays Rainfall"]
};
return {payload:[m]};

Long story short the data is rainfall sum from my database and is in inches. I've been running it this way for 3 years. I wish now to modify it to mm (*25.4) before returning the message to my chart. Could somebody please explain how I can do this inside of this function.

This is how the data appears when returned:

[{"series":["Rainfall"],"data":[0.293],"labels":["Todays Rainfall"]}]

Thanks
Derek

var m = {
  "series": ["Rainfall"],
  "data": [msg.payload[0]["sum(RAINFALL)"] * 25.4],
  "labels": ["Todays Rainfall"]
};
return {payload:[m]};

Thanks Steve. I gave up trying to put it in the right place!

Thanks for your help.
Derek

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