Retrieve Weather Data from Netatmo for WorldWeather Plugin xml

pur_berger

Super User
  • Team MediaPortal
  • Super User
  • May 14, 2007
    1,679
    83
    47
    Vienna
    Home Country
    Austria Austria
    Country flag
    THX to Rick164 who is helping me out getting the local Data from your Netatmo Device with building a App :)

    Attached an basic first version that tests the authentication part, according to the docs:

    https://dev.netatmo.com/doc/authentication/usercred

    it requires 4 authentication strings mainly ID / secret / username / password which is pretty strict as you would only expect the need for the ID/secret in most other APIs, you can test it out and see if you can get an valid result (400 means invalid auth).

    The idea is to fill the data to the local weather condition file from WorldWeatherPlugin to get your own values to MP.

    Code:
    <?xml version="1.0" encoding="UTF-8"?>
    <data>
    
    <provider>
    <name>WorldWeather</name>
    <version>1.0</version>
    </provider>
    
    <location>
    <city>Munich</city>
    <country>Germany</country>
    <region>Bavaria</region>
    <postalcode>80331</postalcode>
    <longitude>11.58</longitude>
    <latitude>48.15</latitude>
    <altitude>500</altitude>
    <unit>SI</unit>
    </location>
    
    <current>
    <date>2013-01-01</date>
    <temperature>16</temperature>
    <temperatureFeelsLike>15</temperatureFeelsLike>
    <weatherCode>26</weatherCode>
    <weatherDescription>Partly Cloudy</weatherDescription>
    <windSpeed>7</windSpeed>
    <windDirectionDegree>280</windDirectionDegree>
    <precipitation>0.0</precipitation>
    <pressure>1026</pressure>
    <barometricPressure>2</barometricPressure>
    <humidity>68</humidity>
    <visibility>0</visibility>
    <cloudCoverage>10</cloudCoverage>
    <uvIndex>1</uvIndex>
    </current>
    
    <forecast>
    <forecastday>
    <date>2013-01-02</date>
    <temperatureLow>8</temperatureLow>
    <temperatureHigh>20</temperatureHigh>
    <weatherCode>25</weatherCode>
    <weatherDescription>Mostly Cloudy</weatherDescription>
    <windSpeed>7</windSpeed>
    <precipitation>2.0</precipitation>
    <pressure>1028</pressure>
    <humidity>68</humidity>
    <cloudCoverage>10</cloudCoverage>
    </forecastday>
    </forecast>
    
    </data>
    https://github.com/RickDB/NetAtmo.Net/tree/master/NetAtmo.NET
     

    Attachments

    Last edited:

    Rick164

    Super User
  • Team MediaPortal
  • Super User
  • January 7, 2006
    1,335
    113
    Home Country
    Netherlands Netherlands
    Country flag
    This version should fill in the Access token directly into the read-only text box below and added the option to get the device ID (untested), weather info is next but would need to know what output XML it needs to generate (format / structure) and if it has to be one XML file or a new one per hour for instance (containing humidity/temp etc..) :)
     

    Attachments

    pur_berger

    Super User
  • Team MediaPortal
  • Super User
  • May 14, 2007
    1,679
    83
    47
    Vienna
    Home Country
    Austria Austria
    Country flag
    Have put the xml details in the first post. With the new version I get

    upload_2014-12-28_18-59-12.png
     

    Rick164

    Super User
  • Team MediaPortal
  • Super User
  • January 7, 2006
    1,335
    113
    Home Country
    Netherlands Netherlands
    Country flag
    New version attached, now includes the JSON library to get rid of that error ;)
    Will make some sample code for each function (auth->device ID->weather info) and put that on github once it works.

    Could format it similar like in the first post but not sure how that would work as you might not get enough information from the NetAtmo API.
     

    Attachments

    Last edited:

    Rick164

    Super User
  • Team MediaPortal
  • Super User
  • January 7, 2006
    1,335
    113
    Home Country
    Netherlands Netherlands
    Country flag
    Nice, gonna check the JSON code and fix it :)
     

    pur_berger

    Super User
  • Team MediaPortal
  • Super User
  • May 14, 2007
    1,679
    83
    47
    Vienna
    Home Country
    Austria Austria
    Country flag
    OK - smal redesign of the icon (as this is the only thing I can do :))
    Icon.png
     
    Last edited:

    Rick164

    Super User
  • Team MediaPortal
  • Super User
  • January 7, 2006
    1,335
    113
    Home Country
    Netherlands Netherlands
    Country flag
    Fixed the bugs and it can now retrieve temperature and humidity from the last 30 minutes, it retrieves the auth and device ID on error (token expired for instance)

    Couldn't find a clear way of knowing which values belong to which as the SDK example only lists those two:

    https://dev.netatmo.com/doc/sdk/win8
    https://dev.netatmo.com/doc/methods/getmeasure

    Code is also up on github:

    https://github.com/RickDB/NetAtmo.Net/tree/master/NetAtmo.NET


    /edit:

    found out how it formats the response, pretty easy now that I get it :p
    Basically we request values (temp/hum in example) and it will list them in that order, can add more like C02 etc.. but depends on how much information we can retrieve and is actually useful in the WorldWeather plugin.

    /edit 2: added some more values (long/lat etc..) to the retrieval and it will display them in the UI, think that is all the info we can get from the device API at least:

    https://dev.netatmo.com/doc/methods/devicelist

    New version attached and added version number to the title.
     

    Attachments

    Last edited:

    pur_berger

    Super User
  • Team MediaPortal
  • Super User
  • May 14, 2007
    1,679
    83
    47
    Vienna
    Home Country
    Austria Austria
    Country flag
    Looking good. Only thet the data is from the Indoor Module (The ID in fact is teh mac adress of teh indoor one which acts as hub for the outdfoor one.

    So Think you need to go for the module_id instead (or in addition)

    module_id
    Optionnal
    If you don't specify any module_id you will retrieve the device's measurements. If you specify a module_id you will retrieve the module's measurements.

    CO2 would be funny but therer are no variables set for this from worlweather and no skinsupport so far (well would be easy to implement this value but no idea what happens if there are not named values in the xml). The public token could be nice to get a temperature / rain / Wind and whatever for your area like this

    http://community.wolfram.com/groups/-/m/t/344241
     

    Users Who Are Viewing This Thread (Users: 0, Guests: 1)

    Top Bottom