Author Topic: feature request: relay of data_requests of bridged vera's. With prototype code  (Read 1093 times)

Offline amg0

  • Sr. Hero Member
  • ******
  • Posts: 2484
  • Karma: +153/-8
Does the JavaScript request cope with HTTP redirects?  It would be much more efficient simply to return a redirect and let AltUI retrieve the result directly from the remote Vera.

I tried this once with a video stream and it didn't work, but I think this may be different?

unfortunuately redirect wont work with ajax calls, ALTUI is not a browser and redirects are feature of a browser.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 5128
  • Karma: +221/-67
  • "Less is more"
unfortunuately redirect wont work with ajax calls, ALTUI is not a browser and redirects are feature of a browser.

I was afraid of that.  :(

However, I've added a couple of lines to the scheduler and the bridge so that now you can make an action call to any bridged device to discover its remote IP.  This should greatly ease the implementation of Rene's code.

I still need to think through the further ramifications of the proposed change.
3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P.
Razberry, MySensors Arduino, HomeWave, AltUI, DataYours, openLuup, ZWay, ZeroBrane Studio.

Offline reneboer

  • Hero Member
  • *****
  • Posts: 1090
  • Karma: +56/-30
Hi akbooer,

After updating openLuup I added my bit of code again, running just fine with it in. I am interested in your comment on making it simpler to find the remote IP. I looked at the VeraBridge code and not able to find anything. Where can I find what you added for that?

I would still like to see this bit added. It makes the user experience a little better in my opinion.

On other topic; I removed the logging in io.lua for successful reads, writes and especially incoming. Those log so many lines it makes it hard to find what I am looking for. Can you make those only log for debug purposes?

Cheers Rene
2xVeraLite, VeraEdge, openLuup, ALTUI, 20 switches, 10 dimmers, 20 sensors, 10 scene controllers, 1 Harmony Hub, many plug-ins. Not enough time.

Offline akbooer

  • Moderator
  • Master Member
  • *****
  • Posts: 5128
  • Karma: +221/-67
  • "Less is more"
After updating openLuup I added my bit of code again, running just fine with it in.

OK, I haven't forgotten about this, but the current implementation breaks a key design rule for the server, which should have non-blocking I/O, but inserting an in-line HTTP request does block, so I'm looking for a way around this.

Quote
I am interested in your comment on making it simpler to find the remote IP. I looked at the VeraBridge code and not able to find anything. Where can I find what you added for that?

There should be a tiny change to the bridge, I added the "remote_ip" action which you can invoke with either an HTTP request or a direct call, thus:

Code: [Select]
local _,_,_,args = luup.call_action ("urn:akbooer-com:serviceId:VeraBridge1", "remote_ip", {}, 10004)

Any bridged device responds to this call with a return parameter table in 'args', containing the IP field. For example:

Code: [Select]
{IP = "172.16.42.14"}

No need to find the right bridge, walk the devices tree, or know the bridge block size, or anything like that.

Quote
I would still like to see this bit added. It makes the user experience a little better in my opinion.

As above, it's not forgotten, but it's not easy to do.

Quote
On other topic; I removed the logging in io.lua for successful reads, writes and especially incoming. Those log so many lines it makes it hard to find what I am looking for. Can you make those only log for debug purposes?

Yes, I used not to log successes, but found that I needed them for spotting some problems.   The whole error logging thing needs revisiting and I was thinking of including a browser capability for warnings/errors in the new console interface.  I currently haven't implemented a debug-level of diagnostics (although the action request to invoke it is there.)

3x Vera Lite-UI5/Edge-UI7, 25x Fibaro, 23x TKB, 9x MiniMote, 2x NorthQ Power, 2x Netatmo, 1x Foscam FI9831P.
Razberry, MySensors Arduino, HomeWave, AltUI, DataYours, openLuup, ZWay, ZeroBrane Studio.

Offline reneboer

  • Hero Member
  • *****
  • Posts: 1090
  • Karma: +56/-30
Hi akbooer,

Ok, understand on the non-blocking. I will do some thinking on alternatives too. Maybe tweak the JS UI code for running on openLuup and finding a bridged device is then a better way to go and redirect the request to the actual Vera hander. I'll keep you posted.

Cheers Rene
2xVeraLite, VeraEdge, openLuup, ALTUI, 20 switches, 10 dimmers, 20 sensors, 10 scene controllers, 1 Harmony Hub, many plug-ins. Not enough time.