Function to write Netatmo measurement in Influx DB


The Netatmo "Get Measurements" node reads the days minimum termperature from my Netatmo outdoor module and when I fill in


in the debugger the correct measurement (degrees minimum temperature value like 15.3) is shown in the debug frame. Now I intend to save this value in an Influx DB and I suppose I need a function before saving the value in the database. After reading many instructions I did not succeed, can someone help me writing this function?

Regards, Hans.

You can use a change node to setup the message for influx.

Thanks Colin, just tried the Change node but no succes. Not even after reading the node help, can you be more specific how to use it in my flow?

Post what you see in a debug node before the change node and another after and show us the change node config. Tell us what you want to see on the output.

Also check that you have configured the influxdb node with the correct details of your database.

When this:


is in my debug node then output in the debugger shows the correct min-temp:

15-7-2019 11:50:04node: 42184b89.07c674msg.payload.devices[0].modules[2].dashboard_data.min_temp : number

So I think I need a function or change to save the min-temp (15) in the database.

The relevant part from the complete message object coming from the Netatmo "get stations data" node is shown in the graphic below.

I am using an influxdb-batch node (with telegraf) and send all netatmo data to it like this:

m = msg.payload.devices[0].dashboard_data

msg.payload = [
        fields: m,
        timestamp: new Date()

return msg

Thanks Bakman2, works like a charm and the data is saved in the DB. Now struggling how to save only the min_temp from the outdoor module, any help would be appreciated.

But if you have it in the database, it is already saved no ?

The indoor module data is saved, not the outdoor module data. I think msg.payload.devices[0].dashboard_data refers to the indoor module.

Sorry, you can use:

m = msg.payload.devices[0].modules[0].dashboard_data

and for min-temp only:

m = msg.payload.devices[0].modules[0].dashboard_data.min_temp
1 Like

Thanks again for helping! Although the line m = msg.payload.devices[0].modules[0].dashboard_data writes to the DB but unfortunattely only the values for Rain, sum_rain_1, sum_rain_24 and time_utc

And the line m = msg.payload.devices[0].modules[0].dashboard_data.min_temp generates an error:

Error: A 400 Bad Request error occurred: {"error":"unable to parse 'tuin': missing fields"}

You have multiple modules.

Connect the netatmo node to a debug node and determine in which module the min_temp is located.

Solved, thanks for helping!

Just wondered why you were adding a timestamp. I thought Influx added it automatically anyway....

You are correct, it is a historical leftover, good moment to clean it up!

1 Like