Author Topic: Version 4 feedback  (Read 9485 times)

Offline jbrink

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
Re: Version 4 feedback
« Reply #15 on: March 25, 2016, 11:16:55 am »
Hello Fellow user...

Have you already solved your auth. problem? I have got exactly the same as you mention, and can still nog work out what i am doing wrong.

Thanks,

Jan

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: Version 4 feedback
« Reply #16 on: March 25, 2016, 12:42:45 pm »
If you're using UI7, are you, in fact, ticking the box required before entering the appropriate text?
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 jbrink

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
Re: Version 4 feedback
« Reply #17 on: March 26, 2016, 06:24:52 am »
Goodmorning akboer,

Yes, boxes are ticked, 4 values added, it does save the values, but the failures stays...

Jan

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: Version 4 feedback
« Reply #18 on: March 26, 2016, 06:36:30 am »
...and you are, of course, sure that you have all the characters correct and have put ClientId and ClientSecret in the right boxes?  One thing: if you have any non-alphanumeric character in your password you might just try changing it (on the Netatmo site) so that it doesn't and trying again.
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 jbrink

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
Re: Version 4 feedback
« Reply #19 on: March 26, 2016, 10:28:50 am »
There is a non alphabetic character, will change that.

Offline jbrink

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
Re: Version 4 feedback
« Reply #20 on: March 26, 2016, 10:48:43 am »
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?

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: Version 4 feedback
« Reply #21 on: March 26, 2016, 11:23:43 am »
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?

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

----

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 jbrink

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
Re: Version 4 feedback
« Reply #22 on: March 26, 2016, 11:37:00 am »
it replies "code failed"

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: Version 4 feedback
« Reply #23 on: March 26, 2016, 12:11:58 pm »
Then you have a more fundamental problem (like your credentials are not correct.)

You are running this on UI7?
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 jbrink

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
Re: Version 4 feedback
« Reply #24 on: March 26, 2016, 12:16:28 pm »
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...

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: Version 4 feedback
« Reply #25 on: March 26, 2016, 12:42:42 pm »
Can you change the last statement in the code from "return ok" to "return true" and rerun?
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 jbrink

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
Re: Version 4 feedback
« Reply #26 on: March 26, 2016, 01:03:13 pm »
Success, code sent successfully !

That is the new reply.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: Version 4 feedback
« Reply #27 on: March 26, 2016, 01:11:21 pm »
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:

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

  • Newbie
  • *
  • Posts: 12
  • Karma: +0/-0
Re: Version 4 feedback
« Reply #28 on: March 26, 2016, 02:17:45 pm »
only an @ (j.brink (at) instaan.nl

further no special numbers....

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6343
  • Karma: +288/-70
  • "Less is more"
Re: Version 4 feedback
« Reply #29 on: March 26, 2016, 02:41:39 pm »
Yes, that's fine.  I forgot is was an email address.  Mine's similar, but with an underscore too.
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.