Hi all,
New to node-red here, and looking to store some IoT data coming from TTN into a postgres database.
I am having a hard time formatting the data.
Here is the payload I receive
4/21/2023, 1:19:29 AM[node: msg.payload](http://xx.xxx.xx.xxx:1880/#)v3/xxxxx@sxxxx/devices/eui-x/up : msg.payload : Object
object
Bat: 3.354
TempC_DS18B20: "0.0"
conduct_SOIL: 89
temp_SOIL: "21.04"
water_SOIL: "22.02"`
Here is the function I use to format the data :
msg.payload = {
timestamp_data: new Date(),
device_battery: parseFloat(msg.payload.Bat),
soil_conductivity: parseInt(msg.payload.conduct_SOIL),
soil_temperature: parseFloat(msg.payload.temp_SOIL),
soil_humidity: parseFloat(msg.payload.water_SOIL)
};
return msg;
But when I do this here is what I receive :
4/21/2023, 1:33:24 AM[node: msg.payload](http://xx.xxx.xx.xxx:1880/#)v3/xxxxx@sowit/devices/eui-x/up : msg.payload : Object
{ timestamp_data: "2023-04-21T01:33:23.953Z", device_battery: NaN, soil_conductivity: NaN, soil_temperature: NaN, soil_humidity: NaN }
I don't understand why I get NaN instead of the values, happy to get your insights.
Thanks,
HB