A lot of people are checking the weather every day. Keeping track of their own temperature is easy using a weather station like Netatmo. You install it in your home and check the current temperature on the phone. But what if you like to save the temperature each day in a database? You use FileMaker!
I have a Netatmo weather station myself and spent a couple of hours this morning to create a small FileMaker database to gather historical data. Using the new JSON functions in FIleMaker 16 it is easier than before. Netatmo saves all your data in ”the cloud”, your phone is asking the cloud for information, and is easy to use FileMaker to get data from the cloud instead.
You need to create an account at Netatmo, and create a Netatmo ”app” for OAuth authentication. You enter your email address and a password at the Netatmo developers web site, Netatmo creates two values for you: a client id and a client secret. Keep the numbers in a safe place.
You use the four values to get an access token. The access token is then used to get the data from Netatmo. You don’t need to send you credentials to Netatmo every time, only the access token. The access token is valid for a couple of hours, then you need to refresh it with another call to Netatmo,
FileMaker use the Insert from URL script step to communicate with Netatmo, getting the access token and the weather data.
In the sample database (you can download it below) you need to enter the four initial values (email address, password, client id and client secret) in the top right corner, it is 4 global fields. When you click the Get weather data button for the first time, FileMaker automatically asks for an access token before getting the data. The next time you click the button, FileMaker will refresh your access token if needed using another call to Netatmo.
The data is returned as JSON. I use the JSONGetElement and JSONListValues functions to extract the values I want. In the sample file included I have extracted the most common values, but there are more values you might find interesting. In that case you need to create more fields in the presentation table and add more script steps to extract the values in the Get weather data script.
Every time I click the button a new record is created in the Data table. Since I have 3 Netatmo modules, an indoor module (”Inomhus” in Swedish), an outdoor module (”Utomhus”) and a rain gauge (”Regnmätare”), I also create 3 records in the Presentation table. The Presentation table is displayed in a portal for each Data record.
The script can of course be scheduled, the best result might be if you open the database on a server and schedule a server script.
Use the sample database ”as is”, or make any changes you like. You probably need to adopt the database to your Netatmo setup. I believe the sample file can be improved!
Download the sample file: Netatmo.fmp12