Hi it's been awhile since I haunted this forum... been busy I guess. I am working with an IOT device sending temp and humidity to NR through an MQTT server on my Raspberry Pi. I am using Node red to put this into a table on a MariaDB on the Pi from there I am trying to bring that info back to a graph in NR. I have gotten most of it working as I like except the graph when I bring it back from MariaDB. The data comes back like this.
{"id":1,"ts":"2022-11-28T04:10:20.000Z","masterTemp":"23.4","masterHum":"41","dateInt":null}
This displays only the time see screen shot.
I think this is due to the "T" and the "Z" in the string but I'm not sure and I am stumped with removing it.
This is the code that is looping through the data and prepping it for the chart input.
var series1 = [];
var series2 = [];
//loop each row and build an array in the required format
for (let index = 0; index < msg.payload.length; index++) {
const e = msg.payload[index];
//var t = new Date(e.ts).valueOf()
var t = new Date(e.ts).valueOf();
series1.push({ "x": t, "y": e.masterTemp });
series2.push({ "x": t, "y": e.masterHum });
}
msg.payload = [
{
"series": ["temp", "humidity"],
"data": [series1,series2],
"labels": [""]
}
];
return msg;
EDIT: I tried something like
var t = e.ts.replace(/T/, ' ');
but that doesn't work.