Netatmo on UI7

Just reporting on progress…

The GOOD news: I’ve successfully accessed the Netatmo servers and obtained an access token from my Edge, so there’s nothing fundamentally wrong with HTTPS procedure calls. Good.

The BAD news: I have yet to discover just WHY the Netatmo app struggles to do this correctly.

A further update:

The GOOD news: the attached updated Lua file works for me… I am up and running on the Edge!! (actually, a rather appropriate name, when you think about it. This really IS on the bleeding Edge!)

The BAD news: something, somewhere, was inserting invalid characters in the request string. This is not anything to do with my code which runs perfectly OK on other platforms. So, it’s really rather worrying that a minor refactoring of the code (a one line change with equivalent semantics) makes this go away. In the old days, I would have said it’s a ‘compiler error’. I find it inconceivable that there’s a fundamental problem in the Lua interpreter unless the Vera folk have changed anything.

HOWEVER, try this, and PLEASE let me know how/whether it works for you.

Uploaded the new file and I am glad to report ‘Can’t Detect Device’ error is gone on my Vera Lite (1.7.481).

I uploaded the L_netatmo.lua file without issue to my Vera Edge. I had the reloaded LUUP after upload checked. Still cannot find device and authorization failed. I reloaded the engine. I logged in and out. Still no luck. I had great success with the previous upload that allowed me to access the advanced settings screen. I have verified my credentials and the client and secret. I see an L_netatmo2.lua and am assuming that this file is unrelated. Please advise what I should try. Thanks

That file is required, but separate in function from the [tt]L_Netatmo.lua[/tt] file I posted.

Further debugging would require recovering the data that the plugin writes to the log file (and I will enhance that specifically to look at this problem - it’s how I solved it for myself, but it seems that the fix may not be universal?) Are you able to do that?

Hi tdavis312,

In an other plug in on UI7 I installed, one of the input fields ended up with the characters
in it and of course I could not get it working for the life of me. The characters did not show on screen and rekeying the value would not clear it. I added every variable to the log output and only then I saw the
characters. Maybe you have a similar issue in one of the authentication fields. I managed to clear the culprit variables with luup.variable_set in the luup test window and after that reentered the values.

No idea if that is what has happened in your case, but it may explain why this authentication issue seem to happen to some and not others, and/or UI7 whilst the same credentials are working on UI5.

Cheers Rene

[quote=“reneboer, post:46, topic:185616”]In an other plug in on UI7 I installed, one of the input fields ended up with the characters
in it and of course I could not get it working for the life of me. The characters did not show on screen and rekeying the value would not clear it. I added every variable to the log output and only then I saw the
characters. Maybe you have a similar issue in one of the authentication fields. I managed to clear the culprit variables with luup.variable_set in the luup test window and after that reentered the values.

No idea if that is what has happened in your case, but it may explain why this authentication issue seem to happen to some and not others, and/or UI7 whilst the same credentials are working on UI5.[/quote]

Kudos (and Karma) to you again! This is EXACTLY what I found in my password string (but not visible on the Advanced tab, only in the logs.) I thought my code refactoring had changed something, but I must obviously have re-entered the password at some point too. So the message is re-enter the credentials.

I am making some specific updates to fix problems for UI7 and will post documentation and code updates on this thread.

Starting with the current App Store install, a number of files need updating…

[ul][li]JSON device files (attached zip)[/li]
[li]Netatmo.lua[/li][/ul]

In addition, there seems to be a general UI7 bug which randomly inserts unseen “
” characters into some device variable values. This is a particular killer for username/password fields! The work-around seems to be to re-enter the values (even if they seem to be correct.)

For the next full release I plan to remove the internal graphing capabilities because I don’t think this is much used, and that functionality is better done in a separate app (eg. DataYours.)

[quote=“akbooer, post:47, topic:185616”][quote=“reneboer, post:46, topic:185616”]In an other plug in on UI7 I installed, one of the input fields ended up with the characters
in it and of course I could not get it working for the life of me. The characters did not show on screen and rekeying the value would not clear it. I added every variable to the log output and only then I saw the
characters. Maybe you have a similar issue in one of the authentication fields. I managed to clear the culprit variables with luup.variable_set in the luup test window and after that reentered the values.

No idea if that is what has happened in your case, but it may explain why this authentication issue seem to happen to some and not others, and/or UI7 whilst the same credentials are working on UI5.[/quote]

Kudos (and Karma) to you again! This is EXACTLY what I found in my password string (but not visible on the Advanced tab, only in the logs.) I thought my code refactoring had changed something, but I must obviously have re-entered the password at some point too. So the message is re-enter the credentials.[/quote]
It was a long shot from my end, but glad it is helping. I will report the issue to MIOS. It only happened on the latest UI7 release not before, but they did mess up the display for empty variables so it may be related.
Cheers Rene.

Yet more Karma for that!

I still have auterisation error on vera edge.
I am running ersion: 1.7.906

I installeer the plugin, replaced the xml file so i can see the advance tab.

In the log file i see the

How can i change that?

[quote=“Nike1st, post:51, topic:185616”]In the log file i see the

How can i change that?[/quote]

Try just re-entering the value of the affected device variable in the Advanced tab (do it manually, not cut and paste, making sure you delete everything in the string), restart, then try again.

Well done for finding the offending
in the log! This is definitely something that the Vera folk must fix.

Reading this post a little more carefully…

The solution described there:

[b]I managed to clear the culprit variables with [tt]luup.variable_set[/tt] in the luup test window [/b]and after that reentered the values.

…may not be easily achievable for many people.

Tell me if you’re having this problem still, and we’ll walk you through it.

Unfortunately you are completely correct about “I managed to clear the culprit variables with luup.variable_set in the luup test window and after that reentered the values.” I do not have a clue how to find the offending value or how to clear it. I can see the logs but do not know how to filter for the entries related to the plugin and/or how to force an action that would cause the entries to get logged while under observation. I have uploaded the jSON files in the zip attachment, uploaded the latest lua file. and have hand entered all relevant values in the advanced setup for the device. The device originally worked under UI7 on my Vera. Then it stopped. I can see the device and its spawned devices on my other Vera in Florida so all values are correct. If I get a pointer on ow to fire something off that would cause the offending values to be logged and some advice how to filter for just those lines I could crack this nut. Oh clearing the old value with lump.variable_set is new to me too. Thanks

OK, I guess you’re not running a syslog server either - which would make getting diagnostic information easier.

I will write a little piece of diagnostic code that you can run in the Luup test code page and which will create a web page on Vera that you can easily view.

Thanks a bundle. I monitored and searched the LuaUPnP.log as I changed the variables in the device set up but I did not see anything relevant in that log. I also did the same when I logged into the Vera controller. I saw that the authorization failed but not why nor did I see any variables being sent down other than the common ones.

OK, here’s a bit of code to try:

[ol][li]Go to the Vera page Apps > Develop apps [/li]
[li]paste the following code in Test Luup code (Lua) and click GO[/li][/ol]

-- Netatmo diagnostic code
-- 2015.01.31 @akbooer 
local NetatmoDEV = "urn:akbooer-com:device:Netatmo:1"
local NetatmoSID = "urn:akbooer-com:serviceId:Netatmo1"
local f = io.open ("/www/netatmodiagnostics.txt", "w")
if f then
  for dev,i in pairs (luup.devices) do
    if (i.device_type or '') == NetatmoDEV then
      for _,var in pairs {"ClientID", "ClientSecret", "Username", "Password"} do
        local x = luup.variable_get (NetatmoSID, var, dev) or ''
        local y = table.concat {var, ' = ', x or '?'}
        print (y)
        f: write (y..'\n')
      end
    end
  end
  f:close ()
end
return true

This should create a file which you can access on the web page at: http:<YourVeraIP>/netatmodiagnostics.txt

This file should contain four lines with the key authorization parameters you have entered (viz. [tt]“ClientID”, “ClientSecret”, “Username”, “Password”[/tt])

DO THESE LOOK RIGHT? … or is there a
hidden somewhere in there?

Sorry but I get a CODE FAILED. I copied in the code starting with the 2 comment lines through to the third END

So why didn’t you copy it all?

EDIT: (there are some extra lines at the end. ) Use the [Select] button to select all the code from this page.

sorry I did not see the other lines. I used the select tool this time. But I still get FAILED TO TEST CODE. PLEASE TRY AGAIN