Alternate UI to UI7

I can send you a zip. I’ll send you a PM with an email address you can contact me and I can send files back

Envoy? de mon iPad en utilisant Tapatalk

Thanks for that - will get back to you soon. I still think that the visualization will have to be disabled, if Google is not reachable. The browser caches the majority of the CDN files for a year. In that case the visualization will remain as the main issue.

[quote=“vosmont, post:576, topic:185570”]the “tail -n” on the logs in ALTUI is really useful !

Thanks[/quote]

:slight_smile: indeed. the “search log” also once you know what keywords to put. for instance I put Scene::RunScene as the search parameter to see last recently executed scenes

for all, in case you missed, you can put {0} inside the OS command , and ALTUI will ask you for the value via a dialog box prompt when you try to execute the command.

V 0.60.425

[ul][li]MultiBox support[/li]
[li]localcdn option for d3js[/li][/ul]

Install by Autoupdate or by magic URL : id=action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=CreatePlugin&PluginNum=8246&Version=28101

MORE DETAILS:

it took me a very long time and effort to get this one out. I wanted to be able to support multiple VERA box from the same ALTUI. the easyway would have been to use VeraBridge from akbooer but I wanted to do this from the client side in order to prepare ALTUI for future evolution like support other boxes or API which are not VERA ( who knows … for 100? you get a zWave rasperry board like the jeedom board which seems more powerful for a subset of the price, but I want to keep the same UI ! ).

The amount of architectural changes in AltUI is significant so I appologize in advance for bugs or regressions.

EXPLANATION

[ul][li]MultiBox : support to configure several VERA to be seen inside ALTUI. there is a new variable called ExtraController on the ALTUI device , which should contain nothing ( in case you still want to work with a single VEAR ) or a list of ip addresses for multiple VERAs. do not put your primary vera ip address. this one is allways counted in as the “Main” controller. so if my main is 192.168.1.6 and I run ALTUI from here , I can just put 192.168.1.5 in the ExtraController variable to see this second VERA in ALTUI. Some considerations[list]
[li]Performance : as ALTUI is a javascript app, it can only make call to the main VERA which is the server which rendered the intial web page, that is the so called same domain origine restriction. so to talk to other VERA, ALTUI uses the main VERA is a gateway, hence, this may impact the performance of the main vera, and remote device act a little slowlier[/li]
[li]device scene IDs are now xx.yy where xx is the controller ID allocated by ALTUI and yy is the device ID for a given controller[/li]
[li]Scene, Control panel are contextual to one controller, you cannot create a Multi controller scene. ALTUI is just a client / presentation layer, it is not scene execution engine so it cannot trigger or run scenes ( for now ! ). so a Multi-controller scene still requires a Vera zwave Bridge type of setup. for now the UI only let to create a scene on the main controller. You cannot yet edit a scene on the secondary controller, or anything that requires using the HAG api since this requires a http POST which I have not proxied yet[/li]
[li]Custom Pages can perfectly mix and match widget from multiple controllers, here no issue at all. you do what you want.[/li]
[li]Graphs, OS commands, Lua startup/test, reboot : for now these features are for the main VERA controller only but internally the MultiBox api permits to do it on the secondary VERA so I will probably evolve this a bit[/li]
[li]PLugins from multiple VERA are supported on the plugin page, you see them all and can see their files, even trigger upgrades on the VERA from which the plugin was detected. there is a Known issue if plugins are used on multiple Vera with different version of plugin and different Service S_xx.xml descriptions[/li]
[li]Known issue with camera on secondary VERA but that should be solvable soon[/li]
[li]Category and Room may conflict when used for filtering on device/scene pages. I need to filter not only based on id but to take the controller owning the category or the room also… a bit complex so for later[/li]
[/list]
[/li]
[li]localcdn : explained in earlier post, added d3js. Google gauge remains a question but if worse come to worse, one could rewrite the gauge in d3js SVG primitives for instance and then we would be independant of google , even in local mode[/li][/ul]

Multiple Veras - great!

Slight problem to-day. I have a plugin where I can push a button and an action is executed. The action has three parameters and works fine. I have another button that executes an action with no parameters. It fails with:

Uncaught TypeError: Cannot read property 'length' of undefined  jquery.js.358

I didn’t have time to get more details or do more testing. I’m guessing that this might be an empty parameter list versus a null parameter list. eg a S_XYZ.xml file with say RunTest1 with no , does not work but RunTest2 with an does:

        <action>
            <name>RunTest1</name>
        </action>


        <action>
            <name>RunTest2</name>
            <argumentList>
                <argument>
                    <name>Value1</name>
                    <direction>in</direction>
                    <relatedStateVariable>A_ARG_TYPE_Value1</relatedStateVariable>
                </argument>
                <argument>
                    <name>Value2</name>
                    <direction>in</direction>
                    <relatedStateVariable>A_ARG_TYPE_Value2</relatedStateVariable>
                </argument>
                <argument>
                    <name>Value3</name>
                    <direction>in</direction>
                    <relatedStateVariable>A_ARG_TYPE_Value3</relatedStateVariable>
                </argument>
            </argumentList>
        </action>

Still hoping the dependency on the Google Visualization API can be resolved. It’s the only thing that stops internet offline operation. All the other needed files are available in the browser cache.

Fantastic!

the easyway would have been to use VeraBridge from akbooer but I wanted to do this from the client side...
No point in introducing additional third-party dependencies! However, I do still need VeraBridge to integrate automation (rather than manual control) across multiple Veras.
... in order to prepare ALTUI for future evolution like support other boxes or API which are not VERA ( who knows ... for 100? you get a zWave rasperry board like the jeedom board which seems more powerful for a subset of the price, but I want to keep the same UI ! ).

This is exactly why I’m developing openLuup - which already supports some plugins and most native Luup code on unix platforms (@vosmont also has it running on Windows!)

In the sprit of supporting multiple platforms, can I persuade you to switch the scene creating/editing to use the port 3480 requests described here http://wiki.mios.com/index.php/Luup_Requests#scene, rather than the more obscure (and somewhat outdated?) [tt] /port_49451/upnp/control/hag[/tt] requests ??? Please?!

Anyway, fantastic work - I can barely keep up with it.

I used to , but it failed on some of the scene changes ( like Lua code etc ) so I had to come back to HAG.
I may try again … later as for now, I hits against a wall to fail to implement the proxy for HAG & post for some reasons…
VERA A tries to call the HAG for VERA B

as you know LUA quite well, if you have an idea why this LUA code would fail, let me know…

NOTE: body is hard coded on purpose , for debug

[code]function proxySoap(lul_device,newUrl,soapaction,envelop,body)
debug(string.format(“proxySoap lul_device:%d soapaction:%s”,lul_device,soapaction))
debug(string.format(“body:%s”,body))
– local mybody = string.format(envelop,body)
local mybody=“<s:Envelope xmlns:s=‘http://schemas.xmlsoap.org/soap/envelope/’ s:encodingStyle=‘http://schemas.xmlsoap.org/soap/encoding/’> <s:Body> <u:ModifyUserData xmlns:u=‘urn:schemas-micasaverde-org:service:HomeAutomationGateway:1’> {"devices":{},"scenes":{"scenes_57":{"timers":[],"triggers":[{"name":"Below 1km","enabled":1,"template":"2","device":"94","arguments":[{"id":"1","value":"1"}],"LastEval":1,"last_run":1437379023}],"groups":[{"delay":0,"actions":[]}],"name":"Alexis 1km","lua":"— message\nlocal current = os.time()\nlocal message = &quot;\nBelow 1km. \n Heure:&quot; … os.date(&quot;%c&quot;,current) … &quot;\n&quot;\npushingbox_notify( message )\nreturn true","id":57,"room":"11","modeStatus":"1,2,3,4","paused":1,"favorite":false,"altuiid":"0-57","Timestamp":1437378982,"last_run":1437379024}},"sections":{},"rooms":{},"InstalledPlugins":[],"PluginSettings":[],"users":{}} json </u:ModifyUserData> </s:Body></s:Envelope>”
debug(string.format(“mybody:%s”,mybody))
local result = {}
local request, code = http.request({
method=“POST”,
url = newUrl,
source= ltn12.source.string(mybody),
headers = {
[“Accept”]=“text/plain, /; q=0.01”,
[“Connection”]= “keep-alive”,
[“Content-Type”] = “text/xml;charset=UTF-8”,
[“Content-Length”] = mybody:len(),
[“Accept-Language”]= “en,en-US;q=0.4”,
[“SOAPACTION”]=“urn:schemas-micasaverde-org:service:HomeAutomationGateway:1#”…soapaction
},
sink = ltn12.sink.table(result)
})

	-- fail to connect
if (request==nil) then
	error(string.format("failed to connect to %s, http.request returned nil", newUrl))
	return 0,""
elseif (code==401) then
	warning(string.format("Access requires a user/password: %d", code))
	return 0,""
elseif (code~=200) then
	warning(string.format("http.request returned a bad code: %d", code))
	return 0,""
end

-- everything looks good
local data = table.concat(result)
debug(string.format("request:%s",request))	
debug(string.format("code:%s",code))	

return 1,data

end
[/code]

That all looks distressingly straight-forward, from a Lua point of view.

How does it fail? … you’re saying that this gets sent to the wrong Vera?

[quote=“akbooer, post:589, topic:185570”]That all looks distressingly straight-forward, from a Lua point of view.

How does it fail? … you’re saying that this gets sent to the wrong Vera?[/quote]
it goes to the right vera but I receive a http 500 code back. so there is something that it does not like.
the strange thing is that the same calls work from ALTUI when calling that VERA locally. ( but in that case the hostname/ip are the same )

ALTUI (ip1) javascript => http:POST => VERA (ip1) HAG → works
ALTUI (ip1) javascript => VERA (ip1) lua => http:POST=> VERA (ip2) HAG → fails with http 500

Just a thought on this one… it’s not the old ‘gotcha’ of

[quote=“amg0, post:590, topic:185570”]it goes to the right vera but I receive a http 500 code back. so there is something that it does not like.
the strange thing is that the same calls work from ALTUI when calling that VERA locally. ( but in that case the hostname/ip are the same )

ALTUI (ip1) javascript => http:POST => VERA (ip1) HAG → works
ALTUI (ip1) javascript => VERA (ip1) lua => http:POST=> VERA (ip2) HAG → fails with http 500[/quote]

This is not a web cross-origin problem, is it?

[quote=“akbooer, post:592, topic:185570”][quote=“amg0, post:590, topic:185570”]it goes to the right vera but I receive a http 500 code back. so there is something that it does not like.
the strange thing is that the same calls work from ALTUI when calling that VERA locally. ( but in that case the hostname/ip are the same )

ALTUI (ip1) javascript => http:POST => VERA (ip1) HAG → works
ALTUI (ip1) javascript => VERA (ip1) lua => http:POST=> VERA (ip2) HAG → fails with http 500[/quote]

This is not a web cross-origin problem, is it?[/quote]

no I work around this kind of issue by making the POST call from the lua code handler ( so from the backend server side ) where the cross origin does not apply. it works for all the other calls ( which were of course failing from the client side becasue of CORS )

but that is another good question. it would all be more simple if VERA supported CORS properly. for instance from my Altui on 192.168.1.5 , I would not need the proxy in the lua handler if I could do directly the POST call to http://192.168.1.16/port_49451/upnp/control/hag.
today, if I do this , as expected I receive an error in the console log : “OPTIONS http://192.168.1.16/port_49451/upnp/control/hag 501 (Not Implemented)”

so, second question to your Unix expertise :slight_smile: is there a way to configure VERA web server so that it accepts CORS request and force it to put “Access-Control-Allow-Origin:*” in the header response ?

Sadly (although I definitely ‘do’ Lua) Unix, HTTP, JavaScript, etc, are way beyond me.

Surely there’s SOMEONE out there who does know this stuff.

[quote=“a-lurker, post:586, topic:185570”]Multiple Veras - great!

Slight problem to-day. I have a plugin where I can push a button and an action is executed. The action has three parameters and works fine. I have another button that executes an action with no parameters. It fails with:

Uncaught TypeError: Cannot read property 'length' of undefined  jquery.js.358

I didn’t have time to get more details or do more testing. I’m guessing that this might be an empty parameter list versus a null parameter list. eg a S_XYZ.xml file with say RunTest1 with no , does not work but RunTest2 with an does:

        <action>
            <name>RunTest1</name>
        </action>


        <action>
            <name>RunTest2</name>
            <argumentList>
                <argument>
                    <name>Value1</name>
                    <direction>in</direction>
                    <relatedStateVariable>A_ARG_TYPE_Value1</relatedStateVariable>
                </argument>
                <argument>
                    <name>Value2</name>
                    <direction>in</direction>
                    <relatedStateVariable>A_ARG_TYPE_Value2</relatedStateVariable>
                </argument>
                <argument>
                    <name>Value3</name>
                    <direction>in</direction>
                    <relatedStateVariable>A_ARG_TYPE_Value3</relatedStateVariable>
                </argument>
            </argumentList>
        </action>

Still hoping the dependency on the Google Visualization API can be resolved. It’s the only thing that stops internet offline operation. All the other needed files are available in the browser cache.[/quote]

I have a few bug fix to publish, not sure if this one was one of them.
on my current version, ALTUI device has this Reset UPNP action ( which does nothing … )

    <actionList>
        <action>
            <name>SetDebug</name>
            <argumentList>
                <argument>
                    <name>newDebugMode</name>
                    <direction>in</direction>
                    <relatedStateVariable>Debug</relatedStateVariable>
                </argument>
            </argumentList>
        </action>
        <action>
            <name>Reset</name>
        </action>
	</actionList>

and I can invoke it from the Action dialog box without the problem you mention. please wait the next version and try again at your convenience to see if it is still there
thx a lot !

Sadly (although I definitely ‘do’ Lua) Unix, HTTP, JavaScript, etc, are way beyond me.

Surely there’s SOMEONE out there who does know this stuff.[/quote]

akbooer, you would not believe it, … I found it !
the SOAPACTION header requires double quotes inside the header string so the proper code is

[code]function proxySoap(lul_device,newUrl,soapaction,envelop,body)
debug(string.format(“proxySoap lul_device:%d soapaction:%s”,lul_device,soapaction))
debug(string.format(“body:%s”,body))
local mybody = string.format(envelop,xml_encode(body))
– local mybody=“<s:Envelope xmlns:s=‘http://schemas.xmlsoap.org/soap/envelope/’ s:encodingStyle=‘http://schemas.xmlsoap.org/soap/encoding/’> <s:Body> <u:ModifyUserData xmlns:u=‘urn:schemas-micasaverde-org:service:HomeAutomationGateway:1’> {"devices":{},"scenes":{"scenes_57":{"timers":[],"triggers":[{"name":"Below 1km","enabled":1,"template":"2","device":"94","arguments":[{"id":"1","value":"1"}],"LastEval":1,"last_run":1437379682}],"groups":[{"delay":0,"actions":[]}],"name":"Alexis 1km","lua":"— message\nlocal current = os.time()\nlocal message = &quot;\nBelow 1km. \n Heure:&quot; … os.date(&quot;%c&quot;,current) … &quot;\n&quot;\npushingbox_notify( message )\nreturn true","id":57,"room":"11","modeStatus":"1,2,3,4","paused":0,"favorite":false,"altuiid":"0-57","last_run":1437379024,"Timestamp":1437379040}},"sections":{},"rooms":{},"InstalledPlugins":[],"PluginSettings":[],"users":{}} json </u:ModifyUserData> </s:Body></s:Envelope>”
debug(string.format(“mybody:%s”,mybody))
local result = {}
local request, code = http.request({
method=“POST”,
url = newUrl,
source= ltn12.source.string(mybody),
headers = {
– [“Host”]=“192.168.1.5”,
[“Connection”]= “keep-alive”,
[“Content-Length”] = mybody:len(),
– [“Origin”]=“http://192.168.1.5”,
– [“User-Agent”]=“Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.134 Safari/537.36”,
[“Content-Type”] = “text/xml;charset=UTF-8”,
[“Accept”]=“text/plain, /; q=0.01”,
– [“X-Requested-With”]=“XMLHttpRequest”,
[“Accept-Encoding”]=“gzip, deflate”,
[“Accept-Language”]= “fr,fr-FR;q=0.8,en;q=0.6,en-US;q=0.4”,
[“SOAPACTION”]=“"urn:schemas-micasaverde-org:service:HomeAutomationGateway:1#” … soapaction…“"”
},
sink = ltn12.sink.table(result)
})

	-- fail to connect
if (request==nil) then
	error(string.format("failed to connect to %s, http.request returned nil", newUrl))
	return 0,""
elseif (code==401) then
	warning(string.format("Access requires a user/password: %d", code))
	return 0,""
elseif (code~=200) then
	warning(string.format("http.request returned a bad code: %d", code))
	return 0,""
end

-- everything looks good
local data = table.concat(result)
debug(string.format("request:%s",request))	
debug(string.format("code:%s",code))	

return 1,data

end
[/code]

I have also reverted when possible to use the http api documented in Luup Requests - MiOS, I tested it , so far so good. for scene change, but also for changing scene pause status.
( however I still need the HAG api for some things like changing lua startup )

That’s great! You could write that more pleasantly as

["SOAPACTION"]='"urn:schemas-micasaverde-org:service:HomeAutomationGateway:1#' .. soapaction.. '"'

ie. with single outer quotes, not double, so you don’t have to escape the inner ones.

Or even more clearly

["SOAPACTION"]=[["urn:schemas-micasaverde-org:service:HomeAutomationGateway:1#]] .. soapaction.. [["]]

I love it when a plan comes together… :slight_smile:

V 0.61.453

[ul][li]Many bug fixes for remote functions in multi controller mode[/li]
[li]Rewrote the documentation on first message of this thread in prevision of a future V1.0 release[/li][/ul]

Install by autoupdate, or by magic url : http://:3480/data_request?id=action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=CreatePlugin&PluginNum=8246&Version=28136

EDIT: re-release to fix a bad remote access bug on icons
EDIT2: re-release to fix on custom pages onoff button
EDIT3: re-release to fix on zwave chart

A couple msgs from Internet Exploder. This is the first time that the IE browser has accessed the Altui page. The start up stalls on waiting for data.

[code]
Message: Expected identifier, string or number
Line: 1543
Char: 46
Code: 0
URI: http://172.22.22.3/port_3480/J_ALTUI_verabox.js

Message: Expected identifier
Line: 2575
Char: 116
Code: 0
URI: http://172.22.22.3/port_3480/J_ALTUI_uimgr.js[/code]

IE which version? Also altUI which version? Thanks

EDIT: just tested IE11 and it works ok. Note make sure you try the simpliest configuration first: no localcdn and no extracontroller ( leave both variable empty ) and no url parameters ( lang= or home= )

EDIT: also tested IE8 and it does not work but this is expected, I require a HTML5 capable browser so IE 10 11 ( in normal mode, not in the old compatibility mode, you can verify this also ) Chrome Firefox or tablets