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
----
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?
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.
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>
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.