We have moved at community.getvera.com

Author Topic: Netatmo Weather Station plugin  (Read 220955 times)

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +291/-70
  • "Less is more"
Netatmo Weather Station plugin
« on: August 28, 2013, 06:49:04 am »
--- The Netatmo plugin is now available from the App Store --- http://apps.mios.com/plugin.php?id=4456

BUT SEE THIS POST: for the latest: http://forum.micasaverde.com/index.php/topic,16276.msg179917.html#msg179917 with support for the Rain Gauge AND the updated API.

Following the discussion on this thread http://forum.micasaverde.com/index.php/topic,13489.0.html,  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
  • writes a plain-text file of latest measurements to a location ('/www/Netatmo.txt' by default) which can be read with any browsergenerates reports and plots through a URL request: <yourVeraIP>:3480/data_request?id=lr_Netatmo[/tt]
  • 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:

This requires a json module (inevitably).  I've used 'json-dm' because I already have dataMine installed (who wouldn't?)
  • Download and unzip the attached program files
  • copy the Netatmo.png icon file (e.g. using scp) to the Vera directory  /www/cmh/skins/default/icons/
  • Create a new device setting the device field to D_Netatmo.xml and description to 'Netatmo', or some such name
  • Restart twice

---[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:
  • 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.
  • 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.
  • BlogFilename - defaults to /www/Netatmo.txt

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: for the latest: http://forum.micasaverde.com/index.php/topic,16276.msg179917.html#msg179917 with support for the Rain Gauge AND the updated API.

« Last Edit: June 09, 2014, 09:38:09 am by akbooer »
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline Crismaison

  • Sr. Member
  • ****
  • Posts: 451
  • Karma: +2/-0
Re: Netatmo Weather Station plugin
« Reply #1 on: August 28, 2013, 07:17:53 am »
Again great job. Will you also in the future have the CO and db shown? Or is this not possible?
Vera lite - Everspring smoke & flood detectors - Fibaro doorsensors - 2 Foscams - Greenwave 6 node smartplug - Several Switches -Netatmo - PLEG - Twilio - DropBoxuploader - FindmyIphone user

Offline watou

  • Community Beta
  • Hero Member
  • ******
  • Posts: 889
  • Karma: +44/-12
Re: Netatmo Weather Station plugin
« Reply #2 on: August 28, 2013, 07:26:20 am »
Very cool!  I'm going to have to get one of these weather stations!

Child temperature measurements are presented in the units selected in the Netatmo configuration itself (so you can have Fahrenheit or Celcius).

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:

Code: [Select]
    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

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +291/-70
  • "Less is more"
Re: Netatmo Weather Station plugin
« Reply #3 on: August 28, 2013, 07:37:53 am »
Again great job. Will you also in the future have the CO and db shown? Or is this not possible?

Thanks.  As I mentioned, there is no standard UPnP service for pressure, noise, or CO2, 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. 

3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +291/-70
  • "Less is more"
Re: Netatmo Weather Station plugin
« Reply #4 on: August 28, 2013, 07:47:44 am »
You may have reasons to ignore Vera's temperature scale, ...

Well, yes.  This is just temperature, whereas the Netatmo also gives pressure (and windspeed, ... and more in future).
« Last Edit: August 28, 2013, 09:41:32 am by akbooer »
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline Crismaison

  • Sr. Member
  • ****
  • Posts: 451
  • Karma: +2/-0
Re: Netatmo Weather Station plugin
« Reply #5 on: August 28, 2013, 07:57:46 am »


...
  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......."
Vera lite - Everspring smoke & flood detectors - Fibaro doorsensors - 2 Foscams - Greenwave 6 node smartplug - Several Switches -Netatmo - PLEG - Twilio - DropBoxuploader - FindmyIphone user

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +291/-70
  • "Less is more"
Re: Netatmo Weather Station plugin
« Reply #6 on: August 28, 2013, 09:14:04 am »
I could only dream of writing any script...
would you like to learn so that you can get CO2 and noise levels in separate devices??

Quote
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 sure they could, because I could too (and they knew it) !
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline capjay

  • Hero Member
  • *****
  • Posts: 675
  • Karma: +9/-3
Re: Netatmo Weather Station plugin
« Reply #7 on: August 28, 2013, 06:27:48 pm »
As I mentioned, there is no standard UPnP service for pressure, noise, or CO2, as far as I can tell.  The same is true for wind, rain, etc...

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

Offline Shaigan

  • Full Member
  • ***
  • Posts: 120
  • Karma: +0/-0
Re: Netatmo Weather Station plugin
« Reply #8 on: August 29, 2013, 03:13:39 am »
Or in a "generic sensor"
FGR221 (7) / FGD211 (20) / FGS211 (1) / FGS221 (6) / DSB05 (6) / HAC01 (1) / AN157-6 (3) / HSM02 (7) / SF812 (1) / HEM3 (1) / SSA2 (1) / VeraPlus

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +291/-70
  • "Less is more"
Re: Netatmo Weather Station plugin
« Reply #9 on: August 29, 2013, 03:26:17 am »
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.
« Last Edit: August 29, 2013, 10:26:03 am by akbooer »
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline Shaigan

  • Full Member
  • ***
  • Posts: 120
  • Karma: +0/-0
Re: Netatmo Weather Station plugin
« Reply #10 on: August 29, 2013, 07:02:11 am »
What about customize a device like the heliotrope one ?
FGR221 (7) / FGD211 (20) / FGS211 (1) / FGS221 (6) / DSB05 (6) / HAC01 (1) / AN157-6 (3) / HSM02 (7) / SF812 (1) / HEM3 (1) / SSA2 (1) / VeraPlus

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +291/-70
  • "Less is more"
Re: Netatmo Weather Station plugin
« Reply #11 on: August 29, 2013, 08:37:18 am »
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.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +291/-70
  • "Less is more"
Re: Netatmo Weather Station plugin
« Reply #12 on: August 29, 2013, 11:42:30 am »
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:
  • user-defined os.date() format string for the date/time display on the 'master' device panel
  • force one decimal place for temperature display which is a round number (eg. 17.0 rather than 17)

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.
« Last Edit: August 29, 2013, 12:24:42 pm by akbooer »
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P, 9x Philips Hue,
Razberry, MySensors Arduino, HomeWave, AltUI, AltHue, DataYours, Grafana, openLuup, ZWay, ZeroBrane Studio.

Offline Crismaison

  • Sr. Member
  • ****
  • Posts: 451
  • Karma: +2/-0
Re: Netatmo Weather Station plugin
« Reply #13 on: August 29, 2013, 12:33:46 pm »
Absolutely brilliant
Vera lite - Everspring smoke & flood detectors - Fibaro doorsensors - 2 Foscams - Greenwave 6 node smartplug - Several Switches -Netatmo - PLEG - Twilio - DropBoxuploader - FindmyIphone user

Offline Shaigan

  • Full Member
  • ***
  • Posts: 120
  • Karma: +0/-0
Re: Netatmo Weather Station plugin
« Reply #14 on: August 29, 2013, 02:31:37 pm »
I prefer this way ;)
FGR221 (7) / FGD211 (20) / FGS211 (1) / FGS221 (6) / DSB05 (6) / HAC01 (1) / AN157-6 (3) / HSM02 (7) / SF812 (1) / HEM3 (1) / SSA2 (1) / VeraPlus