NetAtmo Programming

Netatmo Weather Station Shell Script

Update (2019-03-14): Netatmo changed their login process on Mar 7th 2019 – the download link below refers to the updated script on my GitHub page.

I got a lot of feedback for my blog post Read NetAtmo weather station data via Script and Export NetAtmo weather station data to CSV / Excel. A lot of people seem to be interested by using the data from thier Netatmo weather station.

Bernd G. – one of my blog readers, extended my scripts and build a complete Linux shell wrapper around it. That makes it much easier and adds more flexibility to the scripts. Bernd allowed me to post his script on my blog to share it.

Download (hosted on GitHub):

– Download and remove .txt file extension
– chmod +x
– Run the script using ./ -h

The parameter “-h” will display a help message containing all available parameters and options:

usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ... 
            [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
usage: date [-jnu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] ... 
            [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]

Usage: -h [-u <user>] [-p <pass>] -D [OPTIONS]

General options
 -h  Display this help message and exit

 -u <username>
     User to use (default is set in the configuration area of this script)

     A guest user is sufficient.

 -p <password>
     Password to use (default is set in the configuration area of this script)

 -D  Don't fetch data, but get device info and current readings.
     If jq is available, it's used to format and pretty-print the output.

Additional general options for data fetching (not -D) mode only
 -x  Get the data as Excel, not as CSV

 -i  In the output filename, use the module's ID instead of it's name

 -o  <directory>
     Directory to put the received files in (defaults to the current directory)

Date/time selection options (not for -D mode)
 -s <date time>
     Start time (format: 'YYYY-MM-DD HH:MM:SS')

     Defaults to now - 3600 seconds

 -e <date time>
     End time (format: 'YYYY-MM-DD HH:MM:SS')

     Defaults to now

Date/time selection shortcuts (not for -D mode)
 -n <seconds>
     Get data for the last <seconds> seconds

 -y  Get yesterday's data
 -t  Get today's data (00:00:00 until now)
 -d <yyyy-mm-dd>
     Get historical data for the specified day
 -T  Get this month' data

 -L  Get last month' data
 -M <yyyy-mm>
     Get data for the specified month


In -D mode, prints out the received JSON object to STDOUT.

In data fetching mode, generates a separate output file
for each sensor. For the main module e.g. you'll get five different files,
one for temperature, humidity, co2, noise and pressure each.

The files will be placed in your current directory (or in whatever directory
you specified using the -o option).

Filenames are 
    <module>_<sensor>_<time or timerange>.<extension>

        Is the module's name as given in your configuration, or it's
        ID ('aa:bb:cc:dd:ee:ff') if requested via -i.

        Is the name of the sensor as defined by NetAtmo 
        (co2, humidity, noise, pressure, rain, temperature etc.)

    <time or timerange>
        Depends on your request.

        If you request data for a specific day (-d, -y, -t), it will be
        the day (e.g. '2016-01-16'). For today, where you don't get a
        whole day's worth of data (but only from midnight to now),
        a '-(partially)' is added (-> '2016-01-17-(partially)').

        If you request data for a specific month (-M, -L, -T), it will be
        the month (2016-01). For 'this month', where you don't get a whole
        month' worth of data (but only from the 1st to now), a '-(partially)'
        is added (-> '2016-01-(partially)').

        In any other case, it will be the exact timerange as time span
        like '<2016-01-17-10-00-00_2016-01-18-13-42-51>'
        Is 'csv' for csv files, 'xls' for Excel (if requested using -x)

    Some filename examples:


    (generic with -i)

    (specific day)

    (specific month)


$ -h

  Get the help screen

$ -D

  Fetch device information


  Get data for the last hour

$ -n 1800

  Get data for the last half hour (= 1800s)

$ -t

  Get data since midnight until now

$ -T

  Get data since the 1st of the current month until now

$ -y

  Get data for yesterday

$ -L

  Get data for the last month

$ -d 2016-02-17

  Get data for February 17th 2016

$ -M 2016-02

  Get data for February 2016

$ -s '2016-05-03 17:31:15' -e '2016-05-04 12:21:17'

  Get data from 2016-05-03 17:31:15 to 2016-05-04 12:21:17

$ '2016-08-30 17:31:15'

  Get data from 2016-08-30 17:31:15 until now
You may also like
Creating VMware Virtual Machines using PowerCLI
LotusScript: Move all items without a view into Inbox Folder
Export NetAtmo weather station data to CSV / Excel
  • Ulrich
    2019-09-20T21:58:52+02:000000005230201909 at 21:58

    Hello there,
    has netatmo changed the auth-process again? If I enter my credentials in the file and use it with parameter -D, I get the error “Invalid Access token”.

    Thank you

    • Ulrich
      2019-09-26T21:02:11+02:000000001130201909 at 21:02

      Found the mistake. Did it on macOS. Tried it again on Ubuntu. Worked flawlessly as soon as I found out how the MAC Adresses of the modules are generated. Thanks for the script πŸ™‚

  • Artur Krukowski
    2019-09-02T11:05:25+02:000000002530201909 at 11:05

    It is a very useful script. Thanks for posting it. I have two questions:
    1. Can your script overcome the standard NetAtmo limit to download only up to 3 months of data at a time?
    2. I have a problem downloading data from Wind sensor. I get a response (after reducing minimum data to 60):
    {“error”:{“code”:21,”message”:”Filter wind does not exists”}}
    Thank you in advance.
    Best regards,

    • Artur Krukowski
      2019-09-02T11:28:02+02:000000000230201909 at 11:28

      Regarding question 1 from my previous post, i tested that NetAtmo service allows for about 15 month of data to be downloaded at a time. Would you consider adding an option to your script to download data for a whole year as well?
      Thank you in advance.
      Best regards,

  • Torsten
    2018-08-24T23:50:15+02:000000001531201808 at 23:50

    Hello Michael,

    i tried today your script end get with -D along terminal output but with -M 2015-12 an error.

    ./ line 614: [: : integer expression expected
    file size ok
    usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] …
    [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]

    Draussen – humidity -> ./Draussen_humidity_.csv
    date: illegal option — –
    usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] …
    [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
    date: illegal option — –
    usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] …
    [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
    date: illegal option — –
    usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] …
    [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
    date: illegal option — –
    usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] …
    [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
    date: illegal option — –
    usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] …
    [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
    date: illegal option — –
    usage: date [-jnRu] [-d dst] [-r seconds] [-t west] [-v[+|-]val[ymwdHMS]] …
    [-f fmt date | [[[mm]dd]HH]MM[[cc]yy][.ss]] [+format]
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    100 300 0 55 100 245 166 739 –:–:– –:–:– –:–:– 737
    stat: illegal option — c
    usage: stat [-FlLnqrsx] [-f format] [-t timefmt] [file …]

    • 2018-08-28T14:32:39+02:000000003931201808 at 14:32

      Hello Torsten,

      the option “-M YYYY-MM” cannot be use in conjunction with the “-D” option. Also when using “-M YYYY-MM” you must specify your Module-ID, Module-Name and Sensor in the the script in line 16 and below. The Option “-M” will only read the data for the specified sensors and modules.

      kind regards

      Michael Miklis

      • Torsten
        2018-08-30T15:56:54+02:000000005431201808 at 15:56

        Also ich habe es mit -M und ohne extra Optionen getestet, immer noch der selbe Fehler. Per email bekomme ich jedesmal eine Meldung das sich eine Webapp versucht einzulegen.
        Im Script sind die Logindaten hinterlegt und meine GerΓ€te angelegt mit den entsprechenden IDs.

    • 2019-03-09T22:09:37+01:000000003731201903 at 22:09

      Since a few days the script does not retrieve any data. Login to the website works, so there should not be the problem. It seems to have to do something with the access token. If I debug the script, I see the following:

      curl -d ‘access_token=&device_id=70%3Aee%3A50%3A13%3A49%3Aac&type=Rain&module_id=05%3A00%3A00%3A01%3Ad8%3A02&scale=max&format=csv&datebegin=09.03.2019&timebegin=20%3A05&dateend=09.03.2019&timeend=22%3A05&date_begin=1552158329&date_end=1552165529’

      Any idea?


      • 2019-03-10T10:54:22+01:000000002231201903 at 10:54

        Well, at least the part de-DE in the login URL does not work anymore: Page is not found. However, removing it in a browser gives you the login screen but removing it in the script gives you the “wrong access token” error.


        • Hermann
          2019-03-10T11:51:00+01:000000000031201903 at 11:51

          Well, I have the same problem πŸ™ Anybody any idea ?

          • debianatoe
            2019-03-11T23:38:44+01:000000004431201903 at 23:38

            I have the same problem since 8th of March 2019. It seems to me that the term de-DE has been changed to de-de. But obviously there has been changed a lot more. I think Netatmo has provided a change log documentation. Does anybody know how to get it?

        • 2019-03-12T06:47:05+01:000000000531201903 at 06:47


          Netatmo changed the login process. I already fixed it in a python script that I’m using:

          The key changes are as follows:
          – changed the url to /en-us/access/login
          – grab the HTML output and search for a element
          – extract the value string
          – put the value, email and password in the new post request (names of the values changed)
          – send the data to

          after that you are successfully logged in. Hardest part would be to extract the hidden field value using grep or awk. Any help appreciated.


          • debianatoe
            2019-03-13T21:40:55+01:000000005531201903 at 21:40

            TOKEN=$(curl –silent -c $AUTH_COOKIE $URL_LOGIN | grep csrf-token | cut -d= -f3 | awk ‘{print substr(substr($1, 2), 1, length($1)-2)}’)

          • debianatoe
            2019-03-13T22:20:33+01:000000003331201903 at 22:20

            … but I don’t know how to translate this python-code into bash/curl:
            # ———————————————
            # build the payload for authentication
            # ———————————————
            payload = {’email’: username,
            ‘password’: password,
            ‘_token’: token }

            # ———————————————
            # login and grab an access token
            # ———————————————
            req =“”, data=payload)

          • debianatoe
            2019-03-13T22:49:11+01:000000001131201903 at 22:49

            I think I got it:
            curl –silent -d “_token=$TOKEN&email=$USER&password=$PASS” -b $AUTH_COOKIE -c $SESSION_COOKIE $POST_LOGIN > /dev/null

          • 2019-03-14T09:19:15+01:000000001531201903 at 09:19

            I just updated the script on my Github page (see link above)

          • debianatoe
            2019-03-14T18:30:51+01:000000005131201903 at 18:30

            Thank you! Good job.

          • Hermann
            2019-03-16T19:18:28+01:000000002831201903 at 19:18

            Thank you ! You, Sir, are my hero πŸ™‚

  • Daniel
    2018-06-21T08:47:24+02:000000002430201806 at 08:47

    Hi Michael,

    Your script is great! I’m using it since the holiday season last year. I wrote a simple script to monitor it’s data with zabbix πŸ™‚

    Unfortunately broke yesterday.

    At first it gave back a json parsing error. After I removed jq from the system it gives back a site with the following message: “An Error Was Encountered / The action you have requested is not allowed.”

    I’m trying to debug it. Maybe netatmo made something with their API? Do you know anything about this?


    • 2018-06-21T12:57:15+02:000000001530201806 at 12:57

      Hello Daniel,

      Netatmo changed their API URLs. Change the following line from:


      I will update my Blog-Post in the next days.

      • Julio Soto
        2018-06-27T11:46:23+02:000000002330201806 at 11:46

        Sorry replied on the wrong thread πŸ™
        Hi Michael
        Same problem here.
        Get the β€œparse error: Invalid numeric literal at line 1, column 10” error even after changing to

        Will keep an eye on the blog


      • Julio Soto
        2018-06-27T13:27:08+02:000000000830201806 at 13:27

        Working now
        Also had to change it in the listdevices () section πŸ™

        My falt. Sorry for the flood

        • 2018-06-27T20:10:44+02:000000004430201806 at 20:10

          Hello Julio,
          I just updated the script and moved the new version to Github. You can find it via the link in this post.

          Kind regards


  • zuecho
    2017-11-12T20:56:55+01:000000005530201711 at 20:56

    Thanks for the nice script!

    As a mac user small adjustments are needed.
    1. The heavily used date command in the script does not work as expected. Mac ships with BSD date, instead of GNU date. Therefore you need to install gdate (which is the GNU date) and adjust all the date commands in the script.
    2. There is a similar problem with the stat command (line 614). As a mac user you want to change it to “$(stat -f%z “${outfilename}”)”


    • Julio Soto
      2018-06-27T11:45:12+02:000000001230201806 at 11:45

      Hi Michael
      Same problem here.
      Get the “parse error: Invalid numeric literal at line 1, column 10” error even after changing to

      Will keep an eye on the blog

  • Christoph Steffin
    2017-11-08T15:01:05+01:000000000530201711 at 15:01

    Wonderful piece of script…I run it through CygWin on a Windows Server to catch the data. Is it normal, that fetching the data takes around 5 min and sometimes hours per module and sensor? πŸ˜€
    Does anybody else got this behavior?

Leave Your Comment

Your Comment*

Your Name*
Your Webpage