Hurray! Thanks again @Colin
I've now managed to get the timestamp and the device nickname into the payload with the readings.
04/12/2022, 00:15:07node: debug 5
enviro/indoor01 : msg.payload : Object
object
pressure: 1006.46
temperature: 16.43
voltage: 2.581
color_temperature: 0
gas_resistance: 105523
aqi: 14.1
humidity: 62.61
luminance: 0
time: "2022-12-04T00:15:03Z"
nickname: "indoor01"
but as is usually the case with these things (as I've found anyway) when you move past one issue, there's another one waiting for you. This time, when I try and import this data into influx DB there's an error with the timestamp and influx isn't liking the format. I'm not sure what's wrong there, because I thought influx accepted timestamps in this standard timestamp format, from what I've read online anyway. is it that for some reason its thinking this field should be numeric only? This is on a brand new database (or bucket) as well, so I thought it formatted the fields based on their first input?
04/12/2022, 00:15:07node: Influx DB home_sensor (with time)
msg : error
"Error: Expected numeric value for, timestamp, but got '2022-12-04T00:15:03Z'!"
when I import the data without a timestamp this is the format influx creates a timestamp for the records.
I did try a method from a YouTube video where someone had the same issue, they used the following function to convert the time stamp, but I got an error when I tried that.
date = new Date(Date.parse(msg.payload.timestamp));
msg.payload.timestamp = date.ISOString();
return msg;
but it returns an error saying that .ISOString()
is not a function.
I now have another indoor sensor, and an outdoor one, so hopefully once I've got this timestamp issue out the way I'll be able to set the others up.
Thanks again for your help.
James