We have moved at community.getvera.com

Author Topic: openLuup: Nest  (Read 8993 times)

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: openLuup: Nest
« Reply #15 on: October 29, 2015, 04:28:49 am »
Have you installed curl?
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 mda

  • Sr. Member
  • ****
  • Posts: 464
  • Karma: +9/-0
Re: openLuup: Nest
« Reply #16 on: October 29, 2015, 04:33:10 am »
Have you installed curl?

nope. my mac has curl on it as part of the standard os. Do i need to install lau-curl with luarocks or some such? Thanks.

edit: in installed luarocks-5.1 install lua-curl and reloaded the luup engine, but it made no difference. i still do not see any errors in the logs either. Hmmm.
« Last Edit: October 29, 2015, 04:35:34 am by mda »

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: openLuup: Nest
« Reply #17 on: October 29, 2015, 06:38:24 am »
And another reload resulted in an error within init.lua. Unfortunately the logs don't show anything...

Code: [Select]
stack traceback:
        [C]: in function 'error'
        openLuup/init.lua:195: in main chunk
        [C]: ?

...that error should be accompanied with the message "openLuup - no server socket".  Have you cut that from the log?

Anyway, the reason for this failure is that another copy of openLuup must already be running.  The way to kill it is with the HTTP request (from a browser)
Code: [Select]
http://<VeraIP>:3480/data_request?id=exit
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 CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: openLuup: Nest
« Reply #18 on: October 29, 2015, 08:48:53 am »
Just re-tested this morning. So Nest was running, and apparently streaming data about the Nest devices and I issue a reload Luup from AltUI. This is the result and it won't recover until I kill the process and restart. Also attached a pic of the attempt to halt openLuup.

I'll see if running it from the console yields anything additional.

Code: [Select]
> Host: firebase-apiserver07-tah01-iad01.dapi.production.nest.com:9553
> User-Agent: curl/7.43.0
> Accept: text/event-stream
>
< HTTP/1.1 200 OK
< Content-Type: text/event-stream; charset=UTF-8
< Access-Control-Allow-Origin: *
< Cache-Control: private, no-cache, max-age=0
* no chunk, no close, no size. Assume close to signal end
<
{ [5097 bytes data]
^M100  5097    0  5097    0     0   1499      0 --:--:--  0:00:03 --:--:--  2329^M100  5097    0  5097    0     0   1157      0 --:--:--  0:00:04 --:--:--  1597^M100  5097    0  5097    0     0    942      0 --:--:--  0:00:05 --:--:--  1215^M100  5097    0  5097   $
^M100 86637    0 86637    0     0      2      0 --:--:--  8:29:55 --:--:--     0^M100 86637    0 86637    0     0      2      0 --:--:--  8:29:56 --:--:--     0^M100 86637    0 86637    0     0      2      0 --:--:--  8:29:57 --:--:--     0lua: openLuup/init.lua:19$

stack traceback:
        [C]: in function 'error'
        openLuup/init.lua:195: in main chunk
        [C]: ?



And another reload resulted in an error within init.lua. Unfortunately the logs don't show anything...

Code: [Select]
stack traceback:
        [C]: in function 'error'
        openLuup/init.lua:195: in main chunk
        [C]: ?

...that error should be accompanied with the message "openLuup - no server socket".  Have you cut that from the log?

Anyway, the reason for this failure is that another copy of openLuup must already be running.  The way to kill it is with the HTTP request (from a browser)
Code: [Select]
http://<VeraIP>:3480/data_request?id=exit
« Last Edit: October 29, 2015, 09:14:51 am by CudaNet »
openLuup, AltUI, Zway and HomeWave, enough said...

Offline CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: openLuup: Nest
« Reply #19 on: October 29, 2015, 09:12:57 am »
I'd hold off on loading the plugin as It may cause you issues moving forward.

@CudaNet - If i may ask a favor, do you know where i can get the WWN plug in files?

I am using Watou's Nest plugin on my vera because i am on UI5 but since openluup will run the official vera plugin i figure i should use that one now.

Thanks!
openLuup, AltUI, Zway and HomeWave, enough said...

Offline CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: openLuup: Nest
« Reply #20 on: October 29, 2015, 09:22:06 am »
Some additional tests, I restart openLuup from the console (waiting for the Nest http stream to start) then instructed the system to halt (id=exit).

Code: [Select]
requested openLuup exit at Thu Oct 29 08:14:59 2015

Code: [Select]
100  5247    0  5247    0     0     34      0 --:--:--  0:02:34 --:--:--     5
cuda@Ubuntu:/etc/cmh-ludl$
100  5247    0  5247    0     0     33      0 --:--:--  0:02:36 --:--:--     5
100  5307    0  5307    0     0     23      0 --:--:--  0:03:50 --:--:--     0

The Nest stream continues.... Attempting to reload the openLuup results in socket error (obviously).
openLuup, AltUI, Zway and HomeWave, enough said...

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: openLuup: Nest
« Reply #21 on: October 29, 2015, 10:02:35 am »
Some additional tests, I restart openLuup from the console (waiting for the Nest http stream to start) then instructed the system to halt (id=exit).

[...]

The Nest stream continues.... Attempting to reload the openLuup results in socket error (obviously).

Very instructive.  Could you, through AltUI, just do a reload and see whether (a) it does so, and (b) the Nest polling continues.

Thanks
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 akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: openLuup: Nest
« Reply #22 on: October 29, 2015, 11:03:01 am »
OK, I've managed to replicate this (not too shabby since I don't have a Nest to play with.)  The problem is the curl command running in an independent process and not exiting.

The man page for curl says:
Quote
       curl  is  a  tool  to  transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP,
       IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP). The command is designed to  work  without  user
       interaction.

       curl  offers  a  busload of useful tricks like proxy support, user authentication, FTP upload, HTTP post, SSL connections, cookies, file transfer
       resume, Metalink, and more. As you will see below, the number of features will make your head spin!

My head is suitably spinning.

Lua won't exit until the process does, or perhaps until the link to it is closed somehow.  Working on it.

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 CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: openLuup: Nest
« Reply #23 on: October 29, 2015, 11:34:22 am »
Yes, I had to pretty much kill the console as the stream process wouldn't halt... I guess I never imagined that the Nest devices were updated on a persistent stream rather than a web hook of sorts.

OK, I've managed to replicate this (not too shabby since I don't have a Nest to play with.)  The problem is the curl command running in an independent process and not exiting.

The man page for curl says:
Quote
       curl  is  a  tool  to  transfer data from or to a server, using one of the supported protocols (DICT, FILE, FTP, FTPS, GOPHER, HTTP, HTTPS, IMAP,
       IMAPS, LDAP, LDAPS, POP3, POP3S, RTMP, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP). The command is designed to  work  without  user
       interaction.

       curl  offers  a  busload of useful tricks like proxy support, user authentication, FTP upload, HTTP post, SSL connections, cookies, file transfer
       resume, Metalink, and more. As you will see below, the number of features will make your head spin!

My head is suitably spinning.

Lua won't exit until the process does, or perhaps until the link to it is closed somehow.  Working on it.
openLuup, AltUI, Zway and HomeWave, enough said...

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: openLuup: Nest
« Reply #24 on: October 29, 2015, 12:41:35 pm »
Yes, I had to pretty much kill the console as the stream process wouldn't halt... I guess I never imagined that the Nest devices were updated on a persistent stream rather than a web hook of sorts.

Well, that's the Vera approach... I wouldn't have done it like that myself (in fact, when writing the Netatmo plugin, I didn't!)

So, I have a solution.  It is as blunt an instrument as the plugin deserves...

... search for curl processes connected to the Nest developer API website, and the kill them.

I hate special cases, but I really don't know how else to solve this.  Better ideas anyone?
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 mda

  • Sr. Member
  • ****
  • Posts: 464
  • Karma: +9/-0
Re: openLuup: Nest
« Reply #25 on: October 29, 2015, 12:51:50 pm »
I'd hold off on loading the plugin as It may cause you issues moving forward.

yikes, thanks. i will standby.

please let me know if there is any testing i can do to help out.

Offline CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: openLuup: Nest
« Reply #26 on: October 29, 2015, 01:05:23 pm »
So let me see if I'm following you, if your indicating I take a blunt instrument to my Vera device - DONE ! I'm totally in...
OK, seriously - sounds like you're recommending that openLuup kill the stream process on an exit (id=exit) or reload. If so - then absolutely.

Yes, I had to pretty much kill the console as the stream process wouldn't halt... I guess I never imagined that the Nest devices were updated on a persistent stream rather than a web hook of sorts.

Well, that's the Vera approach... I wouldn't have done it like that myself (in fact, when writing the Netatmo plugin, I didn't!)

So, I have a solution.  It is as blunt an instrument as the plugin deserves...

... search for curl processes connected to the Nest developer API website, and the kill them.

I hate special cases, but I really don't know how else to solve this.  Better ideas anyone?
openLuup, AltUI, Zway and HomeWave, enough said...

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: openLuup: Nest
« Reply #27 on: October 29, 2015, 01:40:59 pm »
So let me see if I'm following you, if your indicating I take a blunt instrument to my Vera device - DONE ! I'm totally in...
It's getting that way.

Quote
OK, seriously - sounds like you're recommending that openLuup kill the stream process on an exit (id=exit) or reload. If so - then absolutely.

Yes, exactly so.  I was about to push a solution to GitHub when I found out that not all operating systems are equal in respect of the command line options for 'ps'.

I test on Mac OS, Debian, and OpenWRT.  There are, no doubt, others, and, sadly, this solution is unlikely to work on a PC.  It looks like I'll have to make the 'ps' command user-definable either within openLuup or at the shell level.

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 CudaNet

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1401
  • Karma: +42/-11
  • Chimichanga !
Re: openLuup: Nest
« Reply #28 on: October 29, 2015, 02:59:15 pm »
That's actually a great idea...

So let me see if I'm following you, if your indicating I take a blunt instrument to my Vera device - DONE ! I'm totally in...
It's getting that way.

Quote
OK, seriously - sounds like you're recommending that openLuup kill the stream process on an exit (id=exit) or reload. If so - then absolutely.

Yes, exactly so.  I was about to push a solution to GitHub when I found out that not all operating systems are equal in respect of the command line options for 'ps'.

I test on Mac OS, Debian, and OpenWRT.  There are, no doubt, others, and, sadly, this solution is unlikely to work on a PC.  It looks like I'll have to make the 'ps' command user-definable either within openLuup or at the shell level.
openLuup, AltUI, Zway and HomeWave, enough said...

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: openLuup: Nest
« Reply #29 on: October 29, 2015, 03:35:11 pm »
So the fix is in GitHub.

you need to make sure that your actual startup code (not startup.lua) contains the line

Code: [Select]
luup.attr_set ("ps_command", "ps -x")

...which you can do on a running system with this in the Test Lua window:

Code: [Select]
luup.attr_set ("StartupCode", [[
  luup.attr_set ("ps_command", "ps -x")
]])

Of course, you might need just "ps" instead (OpenWRT, for instance.)

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.