Author Topic: Netatmo plugin no longer connecting  (Read 107 times)

Offline wise72

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Netatmo plugin no longer connecting
« on: November 22, 2018, 04:55:50 am »
As of last evening my netatmo plugin (the one by @akbooer) is no longer connecting / refreshing the data.

I have recently installed and played around with openLuup configuration (on Pi); initially thought I broke something. I backed up everything and did a clean re-install of openLuup, added the netatmo plugin again - not working.

I then went back and re-installed the app directly on the VeraPlus (Vera app strore, no AltUI); not working.

Finally I reset the keys on the netatmo side (& updated them in the app parameters); still not working.

Is anyone experiencing the same issue? Any solution / info on what may be happening? Thx.

Offline wise72

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: Netatmo plugin no longer connecting
« Reply #1 on: November 22, 2018, 05:37:22 am »
I browsed through the logs.

This is what I found on the Vera side:
Quote
50   11/22/18 11:26:05.586   luup_log:209: Netatmo: admin.unit = 0 <0x77322520>
50   11/22/18 11:26:05.587   luup_log:209: Netatmo: admin.pressureunit = ? <0x77322520>
50   11/22/18 11:26:05.587   luup_log:209: Netatmo: admin.windunit = 0 <0x77322520>
50   11/22/18 11:26:05.587   luup_log:209: Netatmo: station name: ma_station <0x77322520>
50   11/22/18 11:26:05.592   luup_log:209: Netatmo: module name: rain <0x77322520>
[wise72 edit: full list of modules]
01   11/22/18 11:26:05.592   LuaInterface::CallFunction_Startup-1 device 209 function init failed [string "ABOUT = {..."]:441: bad argument #1 to 'pairs' (table expected, got nil) <0x77322520>
01   11/22/18 11:26:05.592   LuImplementation::StartLua running startup code for 209 I_Netatmo.xml failed <0x77322520>
03   11/22/18 11:26:05.593   JobHandler_LuaUPnP::m_bReloadCriticalOnly_set now 1 <0x77322520>
03   11/22/18 11:26:05.593   JobHandler_LuaUPnP::m_bReloadCriticalOnly_set now 0 <0x77322520>


This is what I found on the openLuup side:
Quote
2018-11-22 11:06:38.699   luup_log:6: Netatmo: Netatmo initialisation...
2018-11-22 11:06:40.683   luup_log:6: Netatmo: admin.unit = 0
2018-11-22 11:06:40.683   luup_log:6: Netatmo: admin.pressureunit = ?
2018-11-22 11:06:40.683   luup_log:6: Netatmo: admin.windunit = 0
2018-11-22 11:06:40.683   luup_log:6: Netatmo: station name: ma_station
2018-11-22 11:06:40.683   luup_log:6: Netatmo: module name: rain
[wise72 edit: full list of modules]
2018-11-22 11:06:40.685   openLuup.context_switch::  ERROR: [string "L_Netatmo.lua"]:415: bad argument #1 to 'pairs' (table expected, got nil)
2018-11-22 11:06:40.685   openLuup.scheduler:: job aborted : [string "L_Netatmo.lua"]:415: bad argument #1 to 'pairs' (table expected, got nil)


Offline wise72

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Re: Netatmo plugin no longer connecting (SOLVED)
« Reply #2 on: November 22, 2018, 04:52:23 pm »
The logs actually showed that this was not a Netatmo connection issue since the station/module info was available and being processed. That had to be a local issue with the processing of whatever was being received form the Netatmo server. Spent time tracing this issue deeper; turns out this is a funny corner case.

A secondary Netatmo station includes a module which has not reported back for some time (i.e.months) but still associated with the station.

When the table gets built in L_Netatmo.lua it creates and populates the look up table for the Netatmo module/device tree; as this gets done, data for each measurement available in a given module if fetched from the raw Netatmo data structure and translated into the table.

This is done in the function build_measurement. The original loop is assuming that there is always at least one measurement associated with a given module; in this specific case however (dead module) there is none and the pairs function is being asked to process a nil input which it is not prepared to do.

Trivial fix shown below (starting line 415 in D_Netatmo.lua) is working - my stations are back.

Quote
local function build_measurements (m)

  local x = {Battery= m.battery_percent}        -- throw in the battery level for good measure

  if (m.dashboard_data ~= nil) then  -- wise72 edit   
           
    for name,value in pairs (m.dashboard_data) do
      -- remove underscores and change to CamelCase
      local Name = name: gsub ("_(%w)", string.upper): gsub ("^%w", string.upper)
      if type (value) ~= "table" then x[Name] = value end   -- ignore table structures
    end

  end

  -- add dewpoint calculation for modules with temperature and humidity
  if x[T] and x[H] then
    local dp = dewPoint (x[T],x[H])
    x["DewPoint"] = dp - dp % 0.1
  end
  return x
end
« Last Edit: November 22, 2018, 04:59:43 pm by wise72 »