We have moved at community.getvera.com

Author Topic: ALTUI : New Features Suggestions  (Read 83307 times)

Offline akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: ALTUI : Suggestions
« Reply #30 on: September 01, 2015, 11:17:45 am »
does anybody know if there is a standard way to detect when a device receives an update ?
The system itself obviously knows, because it uses that information when you do a HTTP id=user_data request with a DataVersion parameter, in order to give you only the devices which have changed since your last query.  I looked for where it might be held when implementing openLuup, but could not find it anywhere so had to hide it away internally myself as well.

However, this suggests the approach of ALTUI simply keeping an internal table (one entry per device) with a timestamp of when it last received any variable information for that device from the user_data request.
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 amg0

  • Moderator
  • Master Member
  • *****
  • Posts: 3174
  • Karma: +210/-8
Re: ALTUI : Suggestions
« Reply #31 on: September 01, 2015, 12:19:45 pm »
does anybody know if there is a standard way to detect when a device receives an update ?
The system itself obviously knows, because it uses that information when you do a HTTP id=user_data request with a DataVersion parameter, in order to give you only the devices which have changed since your last query.  I looked for where it might be held when implementing openLuup, but could not find it anywhere so had to hide it away internally myself as well.

However, this suggests the approach of ALTUI simply keeping an internal table (one entry per device) with a timestamp of when it last received any variable information for that device from the user_data request.

hummm, thinking about this, ALTUI does maintain a device table and has ALTUI specific info per devices ( like the altuiid of a device). but ALTUI is a client side web app, it is not persistent and not running all time like a deamon or a serve so I think it would not be a reliable way to know if a device got updated or not because you would loose all info when ALTUI is not running.

I do not see much alternatives other than some kind of heuristics on the VERA device level like looking at the "LastUpdate" variable or other things ( like spying the set variables in the logs ...  )

Offline akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: ALTUI : Suggestions
« Reply #32 on: September 01, 2015, 12:29:35 pm »
but ALTUI is a client side web app, it is not persistent and not running all time like a deamon or a serve so I think it would not be a reliable way to know if a device got updated or not because you would loose all info when ALTUI is not running.

I never imagined a scenario where someone was NOT running ALTUI continuously   :o

However, whilst it could be true that the client is not always running, the ALTUI plugin certainly is.  So I'm wondering if the plugin itself could gather this information and pass it to the client?  A loop-back call with luup.inet.wget to 127.0.0.1 with a status request every minute or so, should not be too burdensome and can gather the data you need into a very compressed format for passing to the client.
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 amg0

  • Moderator
  • Master Member
  • *****
  • Posts: 3174
  • Karma: +210/-8
Re: ALTUI : Suggestions
« Reply #33 on: September 01, 2015, 12:45:08 pm »
but ALTUI is a client side web app, it is not persistent and not running all time like a deamon or a serve so I think it would not be a reliable way to know if a device got updated or not because you would loose all info when ALTUI is not running.

I never imagined a scenario where someone was NOT running ALTUI continuously   :o

However, whilst it could be true that the client is not always running, the ALTUI plugin certainly is.  So I'm wondering if the plugin itself could gather this information and pass it to the client?  A loop-back call with luup.inet.wget to 127.0.0.1 with a status request every minute or so, should not be too burdensome and can gather the data you need into a very compressed format for passing to the client.

Conceptually yes...
however that would either require to move the payload of the engine data request loop inside VERA instead of on the client side and it will start to make ALTUI a backend vera CPU consuming app which I still want to avoid at this point so I respect the prime directive : maximum use of the client side power and no extra server side load on vera box other that what UIx would do.  Maybe in the future I do some laser focused variable_watch or things like that, also when VERA is a more powerful hardware; but I do not really wish to go in the direction of the server side engine polling for the short term.

Hopefully the fallback solutions would be ok for now for that particular need.



Offline akbooer

  • Beta Testers
  • Master Member
  • *****
  • Posts: 6387
  • Karma: +292/-70
  • "Less is more"
Re: ALTUI : Suggestions
« Reply #34 on: September 01, 2015, 01:50:19 pm »
OK, understood.  But I prototyped it anyway.  Here a bit of code you can run (once) in Test Lua.

Code: [Select]
local json = require "dkjson"

local devs  = {}
local DataVersion = ''

function status_watcher ()
  luup.call_delay ("status_watcher", 60)
  local url = "http://127.0.0.1:3480/data_request?id=status&DataVersion=" .. DataVersion
  local ok, s = luup.inet.wget (url)
  local info, msg = json.decode (s)
  local now = os.time ()
  if info and info.devices then
    DataVersion = info.DataVersion
    for _,d in pairs (info.devices) do
      devs[tonumber(d.id) or ''] = now    -- update time
    end
  end
end

function status_server ()
  local i = {}
  for d in pairs(devs) do i[#i+1] = d end
  table.sort (i, function (a,b) return devs[a] < devs[b] end)
  local t = {}
  for j,d in ipairs (i) do
    local name = (luup.devices[d] or {}).description or '?'
    t[j] = ("%s [%d] %s"): format (os.date ("%Y-%m-%d %H:%M:%S",devs[d]), d, name)
  end
  return table.concat (t, '\n'), "text/plain"
end

luup.register_handler ("status_server", "devtime")

status_watcher ()
status_server ()

-----

And then issue the request (after a few minutes):
Code: [Select]
http://<VeraIP>:3480/data_request?id=lr_devtime

and get back a list (newest first)
Code: [Select]
2015-09-01 18:45:07 [46] RGBW White
2015-09-01 18:45:07 [42] RGBW Extra
2015-09-01 18:45:07 [64] RGB controller device
2015-09-01 18:45:07 [41] RGBW Master
2015-09-01 18:45:07 [45] RGBW Blue
2015-09-01 18:44:51 [5] Event Watcher
2015-09-01 18:42:51 [47] Data Yours for UI7
2015-09-01 18:42:51 [14] Rain - Rain
2015-09-01 18:42:51 [6] Netatmo
2015-09-01 18:42:51 [68] Guest - CO2
2015-09-01 18:42:51 [25] Indoor - Pressure
2015-09-01 18:42:51 [71] Indoor - Noise
2015-09-01 18:41:08 [43] RGBW Red
2015-09-01 18:41:08 [44] RGBW Green
2015-09-01 18:41:08 [49] Graph
2015-09-01 18:41:08 [51] Dash
2015-09-01 18:41:08 [33] Door Sensor
2015-09-01 18:41:08 [74] Arduino Node 1
2015-09-01 18:41:08 [75] Arduino Light 0 (1)
2015-09-01 18:41:08 [69] GardenRoom - CO2
2015-09-01 18:41:08 [50] Cache
2015-09-01 18:41:08 [73] Arduino Gateway
2015-09-01 18:41:08 [63] Watcher
2015-09-01 18:41:08 [72] Indoor - CO2
2015-09-01 18:41:08 [56] ALTUI
2015-09-01 18:41:08 [31] Outdoor - MaxTemp
2015-09-01 18:41:08 [29] Outdoor - MinTemp
2015-09-01 18:41:08 [76] Rain - SumRain24
2015-09-01 18:41:08 [8] Garage - Temperature
2015-09-01 18:41:08 [9] Studio - Humidity
2015-09-01 18:41:08 [10] Studio - Pressure
2015-09-01 18:41:08 [11] Studio - Temperature
2015-09-01 18:41:08 [7] Garage - Humidity
2015-09-01 18:41:08 [3] Edge MiniMote
2015-09-01 18:41:08 [4] TKB Switch
2015-09-01 18:41:08 [2] _Scene Controller
2015-09-01 18:41:08 [30] Outdoor - DewPoint
2015-09-01 18:41:08 [12] Studio - Noise
2015-09-01 18:41:08 [15] Guest - Humidity
2015-09-01 18:41:08 [21] GardenRoom - Temperature
2015-09-01 18:41:08 [23] Indoor - Humidity
2015-09-01 18:41:08 [24] Indoor - Temperature
2015-09-01 18:41:08 [13] Studio - CO2
2015-09-01 18:41:08 [20] GardenRoom - Humidity
2015-09-01 18:41:08 [18] Outdoor - Humidity
2015-09-01 18:41:08 [19] Outdoor - Temperature
2015-09-01 18:41:08 [16] Guest - Temperature
2015-09-01 18:41:08 [1] ZWave

Save it for later, perhaps!


PS: or maybe @JS007 can use it anyway!
« Last Edit: September 01, 2015, 01:52:40 pm by akbooer »
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 JS007

  • Sr. Member
  • ****
  • Posts: 319
  • Karma: +1/-3
Re: ALTUI : Suggestions
« Reply #35 on: September 01, 2015, 03:20:49 pm »
thanks, that worked easy enough

all my devices show updates in the last minute or so, now I just need a device to stop updating, will take a battery out of a device and wait 10 min see what results are

edit : the door device I took the battery out of still shows updating even with no battery in it
« Last Edit: September 01, 2015, 03:46:14 pm by JS007 »

Offline amg0

  • Moderator
  • Master Member
  • *****
  • Posts: 3174
  • Karma: +210/-8
Re: ALTUI : Suggestions
« Reply #36 on: September 01, 2015, 05:59:40 pm »
thanks, that worked easy enough

all my devices show updates in the last minute or so, now I just need a device to stop updating, will take a battery out of a device and wait 10 min see what results are

edit : the door device I took the battery out of still shows updating even with no battery in it

see V 0.67.646, I show a couple of variable in device control panel page ( if they exists ). it could help but not garanteed to work for 100% of devices.

Offline reneboer

  • Beta Testers
  • Hero Member
  • *****
  • Posts: 1574
  • Karma: +110/-31
Re: ALTUI : Suggestions
« Reply #37 on: September 02, 2015, 07:06:33 am »
Hi,

When you run code on the vera you can get the last changed value from the standard luup.variable_get. That returns the value and last update timestamp. I did read that the timestamp is updated each time the variable is written, even with the same value so it may not be 100% accurate at all times.

But this is not ALTUI related what so ever, so may not help you.

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 dalhoj

  • Sr. Newbie
  • *
  • Posts: 31
  • Karma: +2/-0
Re: ALTUI : Suggestions
« Reply #38 on: September 12, 2015, 01:13:45 pm »
Hi,

Keep up the good Work.

It would be cool if the web page had the posiblity to be fullscreen on Ios devices

I have used these meta in top of some of my websites:

<meta name="viewport" content="width=device-width initial-scale=1.0 maximum-scale=1.0 user-scalable=yes" />
<meta name="viewport" content="initial-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon" href="/custom_icon.png">

regards Jens


Offline amg0

  • Moderator
  • Master Member
  • *****
  • Posts: 3174
  • Karma: +210/-8
Re: ALTUI : Suggestions
« Reply #39 on: September 12, 2015, 04:08:16 pm »
Hi,

Keep up the good Work.

It would be cool if the web page had the posiblity to be fullscreen on Ios devices

I have used these meta in top of some of my websites:

<meta name="viewport" content="width=device-width initial-scale=1.0 maximum-scale=1.0 user-scalable=yes" />
<meta name="viewport" content="initial-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon" href="/custom_icon.png">

regards Jens
i did not know that was possible. its cool, it is in the next version.  it seems that it only works when the user first save the page as an icon on its home page, and then ipad opens it in full screen mode. do you confirm that is the expected behavior ?

Offline dalhoj

  • Sr. Newbie
  • *
  • Posts: 31
  • Karma: +2/-0
Re: ALTUI : Suggestions
« Reply #40 on: September 12, 2015, 05:31:36 pm »
Hi,

Keep up the good Work.

It would be cool if the web page had the posiblity to be fullscreen on Ios devices

I have used these meta in top of some of my websites:

<meta name="viewport" content="width=device-width initial-scale=1.0 maximum-scale=1.0 user-scalable=yes" />
<meta name="viewport" content="initial-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<link rel="apple-touch-icon" href="/custom_icon.png">

regards Jens
i did not know that was possible. its cool, it is in the next version.  it seems that it only works when the user first save the page as an icon on its home page, and then ipad opens it in full screen mode. do you confirm that is the expected behavior ?

Yes that is true, It works like it should. But if you will you can make a .png file there is 114x114 px and make an icon for the site. And link to it with this meta: <link rel="apple-touch-icon" href="/custom_icon.png"> then it uses that image for the "app" on the homescreen.

Offline a-lurker

  • Hero Member
  • *****
  • Posts: 872
  • Karma: +66/-8
Re: ALTUI : Suggestions
« Reply #41 on: September 12, 2015, 05:36:46 pm »
Hello amgo - the work is progressing well !

I have the situation where the internet connection is only available sometimes. When it is unavailable, AltUi will not function. As previously discussed, it is only the availability of the Google graphing library that causes this stoppage. All the other libraries are cached by the browser and are available off line. Can I suggest an "internet available" flag be maintained and be used to enable/disable the menu items that use graphing.

If the network is down, for whatever reason, it would be a major plus to be able run the AltUI.

Offline amg0

  • Moderator
  • Master Member
  • *****
  • Posts: 3174
  • Karma: +210/-8
Re: ALTUI : Suggestions
« Reply #42 on: September 12, 2015, 06:18:23 pm »
Hello amgo - the work is progressing well !

I have the situation where the internet connection is only available sometimes. When it is unavailable, AltUi will not function. As previously discussed, it is only the availability of the Google graphing library that causes this stoppage. All the other libraries are cached by the browser and are available off line. Can I suggest an "internet available" flag be maintained and be used to enable/disable the menu items that use graphing.

If the network is down, for whatever reason, it would be a major plus to be able run the AltUI.

The LocalCDN variable of altUI device is here for that. If not empty, it can point to a web path on Vera where key JS and CSS files can be put, and thus not even depending on the browser cache.

So in that mode , and except for the Google gauge, everything should be functional without Internet.
http://code.mios.com/trac/mios_alternate_ui/browser/localcdn Contains an example of a LocalCDN folder which you could put under /www on your Vera and point LocalCDN variable to it.
For the gauge , I never had the courage yet to rewrite this to have a local one.
The failure of getting the gauge JS files will not prevent altUI from working , gauge will simply not displays. All other d3.js graphic would work.

Hope that helps.

Offline a-lurker

  • Hero Member
  • *****
  • Posts: 872
  • Karma: +66/-8
Re: ALTUI : Suggestions
« Reply #43 on: September 12, 2015, 07:00:59 pm »
The start up of AltUI does appear to be dependent on the availability of the Google graphics library - it is not cached, where as everything else is (for a year). So the LocalCDN folder would not help - the browser already has it all. If the graphics library load fails the library load call back never occurs and AltUi doesn't start up.

The graphic library is also interactive - that is calls are made to the Google servers dynamically by the browser, to do back end graphing work.

Offline a-lurker

  • Hero Member
  • *****
  • Posts: 872
  • Karma: +66/-8
Re: ALTUI : Suggestions
« Reply #44 on: September 12, 2015, 09:20:06 pm »
I have a plugin with some buttons on it. Some buttons run a function immediately and others run a function as a job. Those that are run as jobs fail as the action URL is not issued by AltUI. So for example RunTest works but JobTest fails:

Code: [Select]
        <action>
        <serviceId>urn:testing-org:serviceId:Test1</serviceId>
        <name>RunTest</name>
        <run>runTest()</run>
        </action>

        <action>
        <serviceId>urn:testing-org:serviceId:Test1</serviceId>
        <name>JobTest</name>
        <!-- this can take up to 15 minutes to execute: run it as a job -->
        <job>jobTest()</job>
        </action>

Maybe just a parsing problem of the XML file?