Version 4 feedback

mmmmh…

no result, changed the password, saved it, rebooted de VERA by unplugging power and rebooting. New password is shown in advanced tab, still error Authorization failed. Are there any other settings necessary? besides the login, password, clientid and clientsecret? Password is with numbers and letters, is that a problem?

Try running this code in the test window (you ARE using AltUI, right?.. It has some print statements which you could replace with luup.log() if not.)

You obviously have to replace the four key items with your values.

Does this work?

-- test Netatmo authentication
-- @akbooer 27-May-2015

local client_id       = "your info here"
local client_secret   = "your info here"
local username        = "your info here"
local password        = "your info here"

local socket  = require "socket"
local url     = require "socket.url"
local https 	= require "ssl.https"
local json    = require "dkjson"

local function log (msg)
  luup.log (msg)
  print (msg)
end


	local access_token, refresh_token 	-- updated periodically after authorisation

	-- HTTPS_request(),  HTTPS GET/POST with Lua table body definition and JSON return
	-- see http://notebook.kulchenko.com/programming/https-ssl-calls-with-lua-and-luasec
	local function HTTPS_request (url, params)
		local req, Json 
		if params then 	-- it's a POST (otherwise a GET)
			req = {}
			for name,value in pairs (params) do 
			 req[#req+1] = table.concat {name, '=', value}
			end	-- build the parameter string
			req = table.concat (req,'&')	
		end
		local reply,code, headers = https.request (url, req)		-- body, code, headers, status
		if code ~= 200 then
			log ('HTTPS error = ' .. (code or 'nil'))
			Json = {}
		else
			Json = json.decode (reply)
		end
		return Json, headers
	end

	local function authenticate (username, password, scope)
	  scope = scope or "read_station"
		local reply, hdr = HTTPS_request ("https://api.netatmo.net/oauth2/token",	
			{
				grant_type    = "password",
				client_id     = client_id,
				client_secret = client_secret,
        username      =  (username), 
        password      =  (password),
				scope         = scope,
			} )
		access_token, refresh_token = reply.access_token, reply.refresh_token
		return access_token ~= nil, hdr
	end
		
	local function get_devices ()
		local reply = HTTPS_request ("https://api.netatmo.net/api/devicelist", 
			{
				access_token = access_token
			} )
		return  reply.body	-- ALL device info!
	end

-- run the test

log "Netatmo authorization test"
local ok, hdr = authenticate (username, password)
local msg = "FAILED"
if ok then
  msg = "PASSED OK"
end
print (msg)
print (hdr)

local info = get_devices ()

print (info)

return ok

----

it replies “code failed”

Then you have a more fundamental problem (like your credentials are not correct.)

You are running this on UI7?

Yes,

It is a Veraplus on UI7. version: 1.7.1754

With these credentials I can log in on my netatmo app on my phone… Reentered the client codes, no result…

Can you change the last statement in the code from “return ok” to “return true” and rerun?

Success, code sent successfully !

That is the new reply.

Yes, well, all that means is that the code itself is not at fault. However, the authorization failure is still there. I need to try this on my own UI7 machine…

… just did, and it reports success:

Netatmo authorization test
PASSED OK
table: 0x16b7d28
table: 0x183cde8

…so there’s something strange about your setup.

Do you, perchance, also have a special character (non-alphanumeric) in your username?

only an @ (j.brink (at) instaan.nl

further no special numbers…

Yes, that’s fine. I forgot is was an email address. Mine’s similar, but with an underscore too.

Ak,

PM send.

not possible…

…to send me a PM ??? I get plenty!

I was wondering if there is something odd with your network? Netatmo uses HTTPS requests to remote connections on port #443.

Hi akbooer,

I think I might have discovered a small bug in the Netatmo Plugin.

I noticed yesterday that the plugin had not updated any values for 8 hours and when I went to “my.netatmo(dot)com” I noticed that both the wind and rain sensor had dropped (no longer communicating). The reason they were not communicating was that the weather was so cold that the alkaline batteries were not able to feed enough juice. Later the wind sensor came back but I had to replace the batteries in the rain sensor to also get this one back online.
Once all sensors were back online the Vera Netatmo Plugin started to update all values again.

I was not planing on climbing the roof in the middle of winter just because of the rain sensor, I can live without the rain sensor until spring.
But I can not live with loosing all sensor data just because one sensor is offline.

Any useful information in the log files? Otherwise can try a test by removing batteries from a device, I suppose. I’d be keen to find out whether the problem is actually in the plugin or some feature of the Netatmo API which I don’t understand.

Sorry akbooer,

I did not grab the log files. But as I only replaced the batteries in the rain sensor there is still some possibility that the wind sensor drops again and if the issue happens again I can see what is in the log files. Other wise I will reproduce the issue when spring comes and I can roam the roof without the risk of falling to my death.

Hi,
maybe I have the same problem. The battery on my rain sensor gone and all Netatmo devices have stopped to update.
Here is the error from log about polling:
01 01/18/17 6:18:01.687 LuaInterface::CallFunction_Timer-5 function pollNetatmo failed [string “…”]:286: attempt to perform arithmetic on local ‘value’ (a nil value) <0x7577d520>

It is repeating every 10min.

Seems like it is only the rain sensor that is affected with the update issue. I lost communication with the wind sensor today and all other devices keep updating just fine.

I’ve had the plugin create a new device on some battery changes, but never found a problem that a reload didn’t fix. The plugin is, of course, totally dependent on Netatmo’s API for its functionality. If a device isn’t there on startup, it gets deleted.

I lost contact with my Rain sensor today again and the plugin stoped updating any values.

06 02/14/17 10:27:06.202 Device_Variable::m_szValue_set device: 255 service: urn:upnp-org:serviceId:altui1 variable: e[35;1mDisplayLine1e[0m was: 470 ppm now: 474 ppm #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x753d7520> 06 02/14/17 10:27:06.204 Device_Variable::m_szValue_set device: 7 service: urn:akbooer-com:serviceId:Netatmo1 variable: e[35;1mLastUpdatede[0m was: 1487060225 now: 1487060826 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x753d7520> 01 02/14/17 10:27:06.204 e[31;1mLuaInterface::CallFunction_Timer-5 function pollNetatmo failed [string "..."]:286: attempt to perform arithmetic on local 'value' (a nil value)e[0m <0x753d7520>

Tried a Luup restart but I still get no values from any sensors.

50 02/14/17 11:30:45.721 luup_log:6: Netatmo: station name: Barkamo <0x755ef520> 50 02/14/17 11:30:45.722 luup_log:6: Netatmo: module name: GK <0x755ef520> 50 02/14/17 11:30:45.723 luup_log:6: Netatmo: module name: Ute <0x755ef520> 50 02/14/17 11:30:45.724 luup_log:6: Netatmo: module name: AR <0x755ef520> 50 02/14/17 11:30:45.724 luup_log:6: Netatmo: module name: Regn <0x755ef520> 50 02/14/17 11:30:45.725 luup_log:6: Netatmo: module name: SR <0x755ef520> 50 02/14/17 11:30:45.726 luup_log:6: Netatmo: module name: Vind <0x755ef520> 50 02/14/17 11:30:45.727 luup_log:6: Netatmo: module name: IN <0x755ef520> 06 02/14/17 11:30:45.728 Device_Variable::m_szValue_set device: 6 service: urn:micasaverde-com:serviceId:GenericSensor1 variable: e[35;1mGKTimeUtce[0m was: 1487063852 now: 1487064457 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x755ef520> 06 02/14/17 11:30:45.729 Device_Variable::m_szValue_set device: 17 service: urn:akbooer-com:serviceId:Netatmo1 variable: e[35;1mLastUpdatede[0m was: 1487064425 now: 1487064645 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x755ef520> 06 02/14/17 11:30:45.730 Device_Variable::m_szValue_set device: 6 service: urn:micasaverde-com:serviceId:GenericSensor1 variable: e[35;1mGKAbsolutePressuree[0m was: 1028.3 now: 1028.6 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x755ef520> 06 02/14/17 11:30:45.732 Device_Variable::m_szValue_set device: 18 service: urn:akbooer-com:serviceId:Netatmo1 variable: e[35;1mLastUpdatede[0m was: 1487064425 now: 1487064645 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x755ef520> 06 02/14/17 11:30:45.732 Device_Variable::m_szValue_set device: 6 service: urn:micasaverde-com:serviceId:GenericSensor1 variable: e[35;1mGKPressuree[0m was: 1030.7 now: 1031 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x755ef520> 06 02/14/17 11:30:45.733 Device_Variable::m_szValue_set device: 19 service: urn:micasaverde-com:serviceId:GenericSensor1 variable: e[35;1mPressuree[0m was: 1030.7 now: 1031.0 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x755ef520> 06 02/14/17 11:30:45.734 Device_Variable::m_szValue_set device: 19 service: urn:akbooer-com:serviceId:Netatmo1 variable: e[35;1mLastUpdatede[0m was: 1487064425 now: 1487064645 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x755ef520> 06 02/14/17 11:30:45.734 Device_Variable::m_szValue_set device: 19 service: urn:micasaverde-com:serviceId:GenericSensor1 variable: e[35;1mCurrentLevele[0m was: 1030.7 now: 1031.0 #hooks: 0 upnp: 0 skip: 0 v:0xf85330/NONE duplicate:0 <0x755ef520> 06 02/14/17 11:30:45.735 Device_Variable::m_szValue_set device: 19 service: urn:upnp-org:serviceId:altui1 variable: e[35;1mDisplayLine1e[0m was: 1030.7 mbar now: 1031.0 mbar #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x755ef520> 06 02/14/17 11:30:45.735 Device_Variable::m_szValue_set device: 19 service: urn:micasaverde-com:serviceId:GenericSensor1 variable: e[35;1mAbsolutePressuree[0m was: 1028.3 now: 1028.6 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x755ef520> 06 02/14/17 11:30:45.736 Device_Variable::m_szValue_set device: 254 service: urn:akbooer-com:serviceId:Netatmo1 variable: e[35;1mLastUpdatede[0m was: 1487064425 now: 1487064645 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x755ef520> 06 02/14/17 11:30:45.736 Device_Variable::m_szValue_set device: 6 service: urn:micasaverde-com:serviceId:GenericSensor1 variable: e[35;1mGKCO2e[0m was: 460 now: 452 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x755ef520> 06 02/14/17 11:30:45.737 Device_Variable::m_szValue_set device: 255 service: urn:micasaverde-com:serviceId:GenericSensor1 variable: e[35;1mCO2e[0m was: 460 now: 452 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x755ef520> 06 02/14/17 11:30:45.738 Device_Variable::m_szValue_set device: 255 service: urn:akbooer-com:serviceId:Netatmo1 variable: e[35;1mLastUpdatede[0m was: 1487064425 now: 1487064645 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x755ef520> 06 02/14/17 11:30:45.738 Device_Variable::m_szValue_set device: 255 service: urn:micasaverde-com:serviceId:GenericSensor1 variable: e[35;1mCurrentLevele[0m was: 460 now: 452 #hooks: 2 upnp: 0 skip: 0 v:0xf85330/NONE duplicate:0 <0x755ef520> 06 02/14/17 11:30:45.814 Device_Variable::m_szValue_set device: 255 service: urn:upnp-org:serviceId:altui1 variable: e[35;1mDisplayLine1e[0m was: 460 ppm now: 452 ppm #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x755ef520> 06 02/14/17 11:30:45.815 Device_Variable::m_szValue_set device: 255 service: urn:akbooer-com:serviceId:Netatmo1 variable: e[35;1mIconSete[0m was: 3 now: 8 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x755ef520> 06 02/14/17 11:30:45.816 Device_Variable::m_szValue_set device: 7 service: urn:akbooer-com:serviceId:Netatmo1 variable: e[35;1mLastUpdatede[0m was: 1487064425 now: 1487064645 #hooks: 0 upnp: 0 skip: 0 v:(nil)/NONE duplicate:0 <0x755ef520> 01 02/14/17 11:30:45.817 e[31;1mLuaInterface::CallFunction_Timer-5 function pollNetatmo failed [string "..."]:286: attempt to perform arithmetic on local 'value' (a nil value)e[0m <0x755ef520>