Netatmo Weather Station plugin

— The Netatmo plugin is now available from the App Store — http://apps.mios.com/plugin.php?id=4456

BUT SEE THIS POST: with support for the Rain Gauge AND the updated API.

Following the discussion on this thread, here is a second beta version of a Netatmo plugin with these features (see screenshot attached):

  • mirrors configuration of any number of stations and modules as assigned to your Netatmo account
  • creates one ‘master’ plugin device with all the measurements available as device variables
  • creates child devices for all temperature (with one decimal place!) and humidity sensors
  • generates reports and plots through a URL request: <yourVeraIP>:3480/data_request?id=lr_Netatmo
  • uses HTTPS protocol and handles user authentication and access token rotation correctly

A few more specifics:

  • You should ensure that ALL Netatmo modules in your system have unique names (by default, the basic set are “Indoor” and “Outdoor”, but if you have two systems you will have two of each) because…
  • Luup Netatmo device variables are named from the concatenation of “module” name and “sensor” name, so with a basic configuration you have variables like “OutdoorTemperature” and “IndoorCO2”.
  • Similarly, all the child devices for temperature and humidity are named as “Outdoor - Temperature”, “Indoor - Humidity”, etc.
  • Child temperature measurements are presented in the units selected in the Netatmo configuration itself (so you can have Fahrenheit or Celcius).
  • Temperature and humidity child devices have their own individual parameter ‘CalibrationOffset’. This is found under the Advanced tab of each child device and is simply an offset value which is added to the data (after units conversion) as a crude way of calibrating the sensor measurement (especially humidity.) caveat utilitor (let the user beware)… use it with care when necessary.
  • Temperature and Humidity values are stored under their appropriate variable and service names on the child devices, but I’ve been unable to find services for Pressure, Noise, or CO2.
  • On the master plugin device, all the variables are stored under the service “urn:micasaverde-com:serviceId:GenericSensor1”. These values are as received from the web server in ‘native’ units of Celcius, %, mbar, ppm, dB re ?.

All the configuration variables required are accessed under the Advanced tab of the master device.

Installation and Configuration:

  1. Download and unzip the attached program files[/li]
    [li]copy the Netatmo.png icon file (e.g. using scp) to the Vera directory /www/cmh/skins/default/icons/
  2. Create a new device setting the device field to D_Netatmo.xml and description to ‘Netatmo’, or some such name[/li]

—[Edit: Restarts and browser refreshes are useful after installing the plugin from the App Store]—

You should now have a startup error for the Netatmo plugin with ‘Authorisation failure’. Critical fields to be filled in under the Advanced tab are:

  • ClientSecret
  • ClientID
  • Username
  • Password

You already have Username and Password for your Netatmo account. In order to get keys for ClientSecret and ClientID, you need to register your application at http://dev.netatmo.com/dev/createapp

The final required inputs, set to sensible defaults, are:

[ul][li]TokenRefresh - time (in minutes) after which to refresh the access token for the Netatmo web API. These currently expire after 180 minutes, so the default is 120.[/li]
[li]MeasurementPoll - rate (in minutes) at which to poll for new measurements. The default is 10 minutes. No point in setting to less, as the web API limits the access rate anyway.[/li]
[li]BlogFilename - defaults to /www/Netatmo.txt[/li][/ul]

If this goes smoothly, I will release it in the App Store (if someone tells me how !)

— The Netatmo plugin is now available from the App Store — http://apps.mios.com/plugin.php?id=4456

BUT SEE THIS POST: with support for the Rain Gauge AND the updated API.

Again great job. Will you also in the future have the CO and db shown? Or is this not possible?

Very cool! I’m going to have to get one of these weather stations!

I do wonder if that is the best way to go, instead of using the temperature format of the Vera. Here is a code snippet I use in my thermostat plugins to find out what temperature scale Vera uses:

    local function getVeraTemperatureScale()
      local code, data = luup.inet.wget("http://localhost:3480/data_request?id=lu_sdata")
      
      if (code == 0) then
        data = json.decode(data)
      end

      veraTemperatureScale = ((code == 0) and (data ~= nil) and (data.temperature ~= nil)) and data.temperature or "F"
    end

(You may have reasons to ignore Vera’s temperature scale, but I think it might lead to confusion.)

Great job!

watou

Thanks. As I mentioned, there is no standard UPnP service for pressure, noise, or CO[sub]2[/sub], as far as I can tell. The same is true for wind, rain, etc…

A number of developers here are anxious not to break a standard, but at the same time want to push on with providing this sort of functionality in Vera. See discussion at: http://forum.micasaverde.com/index.php/topic,11815.0.html

I would consider breaking these out into generic child devices, but really need a way to control the proliferation of children for those who don’t want them (no real-life analogies here, please! ). The Vera UI is not really my thing, so I use external apps, HomeWave in particular. Whilst these can display generic data, it’s not pretty. There’s nothing to stop you writing a simple scheduled script and creating a dummy device to display these values individually.

Well, yes. This is just temperature, whereas the Netatmo also gives pressure (and windspeed, … and more in future).


There’s nothing to stop you writing a simple scheduled script and creating a dummy device to display these values individually.
[/quote]

I could only dream of writing any script…also in my real life I am the annoying guy asking the developers “I am sure you can fix/built/change this functionality…”

would you like to learn so that you can get CO[sub]2[/sub] and noise levels in separate devices??

also in my real life I am the annoying guy asking the developers "I am sure you can fix/built/change this functionality......."
As I have been, but I was [u]sure[/u] they could, because I could too (and they knew it) !

I guess you can always dump these into a VContainer :slight_smile:

Or in a “generic sensor”

I tried that already, but unfortunately, the “out of the box” implementation of GenericSensor is a crudely and incompletely modified light sensor which does not display its value on the Vera UI panel. — Edit: that bit is wrong, my mistake —

If display is all that you’re after, then it’s easy enough to fashion specific child devices for pressure, etc. I may add the option to specify which classes of measurement should be split out into child devices.

What about customize a device like the heliotrope one ?

I would have liked to have used a standard device available on every Vera, and known to UPnP.
Writing something custom is not really a problem, but just leads to a non-standard solution.

OK, is this more like it (see attached screen shot) ?

I have added a user-defined variable to select which sensor types from {Temperature, Humidity, CO2, Pressure, Noise} separate child devices will be created. The new devices are customisations (so that they can have individual icons) but they provide the data in the standard “GenericSensor1” service. The icons are all public domain from http://www.iconarchive.com/

Other changes:

[ul][li]user-defined os.date() format string for the date/time display on the ‘master’ device panel[/li]
[li]force one decimal place for temperature display which is a round number (eg. 17.0 rather than 17)[/li][/ul]

I’ll release the files when someone tells me what is the meaning of the ‘pressureunit’ parameter in the Netatmo API. Until then, I can’t do a units conversion on the pressure child device so it’s in mbar.

Absolutely brilliant

I prefer this way :wink:

Here are the Beta 3 files - a complete set:

[ul][li]icons.zip - unzip and use scp to copy to Vera’s /www/cmh/skins/default/icons/[/li]
[li]luup.zip - unzip and download to Vera’s Luup files[/li][/ul]

There’s also a screenshot.

New features:

[ul][li]1 decimal place for temperature even if a round number (eg. 17.0)[/li]
[li]user-defined timestamp format string (for use on device panel) - this is the variable TimeFormat which uses the syntax of the os.date() Lua function to allow flexibility of formatting the string shown on the Netatmo ‘master’ device panel in the Vera UI.[/li]
[li]add child device types: Pressure, Noise, and CO2 - they provide the data in the standard “GenericSensor1” service. The pressure is in units defined by the Netatmo configuration (mbar / inHg / mmHg).[/li]
[li]user-defined list of child sensor types - so that the display isn’t cluttered with devices you’re not interested in, then a string defines the types of sensor for which you want to create child devices. This is the variable ChildSensors and the string is searched for occurrences of the upper-case letters “THCPN” (Temperature / Humidity / CO2 / Pressure / Noise), everything else is ignored. Thus “TH” will produce only Temperature and Humidity child devices, “THCPN” (the default) produces everything, as, indeed, does “THe Complete Netatmo Package”. [/li][/ul]

As ever, I’m sure you’ll let me know if this falls short in any way. Equally, it would be good to know that all is working well.

Installed and is working fantastically; the icons are great!
I see that the temperature shows under the climate tab for devices but humidity, co2 and pressure do not

EDIT:
The pressure is not rounding to one digit

Quick work! Glad you like it.

I see that the temperature shows under the climate tab for devices but humidity, co2 and pressure do not
I can do nothing about the humidity, since that is a standard device. I'm not sure if if can force the others. One reason that the icons are monochrome is to subliminally indicate that it's a sort of work in progress.
The pressure is not rounding to one digit
No indeed. I left it floating because, actually, you would need two decimal places if you chose units of inHg. Does it bother you? Temperature bothered me, but I can live with pressure that way.

It doesn’t bother me though preference would to have it rounded to 2 decimal places

I must say, you’ve done an excellent job with this. If anyone is reading this thread and doesn’t have a netatmo, go buy one now and install this plugin!

Actually, since you mentioned it, it does bother me now…

…so here’s an updated file which shows relevant precision (decimal places - dp) for all measurement units:

[ul][li]0 dp: %, dB, ppm[/li]
[li]1 dp: C, F, mbar, mmHg[/li]
[li]2 dp: inHg[/li][/ul]

It actually made the code neater because temperature is not now a special case.

Thanks!

© 2020 Vera Control Ltd., All Rights Reserved. Terms of Use | Privacy Policy