Alternate UI to UI7

V 0.63.496

[ul][li]fix for registerPlugin[/li]
[li]variable and scene execution history in reverse order[/li]
[li]new scene box layout for better resizing[/li]
[li]memory of last entered os command or debug command[/li][/ul]

INSTALL
autoupdate or magic url ?id=action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=CreatePlugin&PluginNum=8246&Version=28236

NOTE: i am submitting this one as a public version too.

[quote=“tomtcom, post:638, topic:185570”][quote=“amg0, post:632, topic:185570”][quote=“tomtcom, post:628, topic:185570”][quote=“amg0, post:612, topic:185570”][quote=“tomtcom, post:610, topic:185570”]I have your latest .462. See the screenshot, this is all I get for Network Quality and zWave Routes. At least now it shows my internal IP where it didn’t before but the screenshot is all I have for both of them.

I know it’s an internal IP but I blurred it because I prefer it, that’s all.[/quote]

Very very strange. need some basic trouble shooting information.
a) did you check for any error in the javascript console ?
b) can you give me a device snapshot ( private email addr if you prefer )
http:///port_3480/data_request?id=user_data&output_format=json

also please note that a [glow=red,2,300]LUA reload plus client browser refresh is required[/glow][/quote]

Here’s the java script console for both graphs. If you can’t figure it out for me then don’t worry, I can live without it. I apologize but the json data file has just to many things to scrub in there so I don’t wish to send it. No disrespect to you in any way, please don’t take it that way.[/quote]

tomtcot, you may try to use this version ( wont install by auto-upgrade, I want to confirm first it fixes your pb )
http://yourip:3480/data_request?id=action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=CreatePlugin&PluginNum=8246&Version=28226

I am still interested by the debug search variable result with : iRoute[/i]
in order to confirm the exact root cause

let me know the result of this version and the variable search dump ( cf screen shot )
thx ![/quote]

Works! With this version Routes and Network Quality now work perfectly.

Is network quality a static picture or should it be moveable? Mind doesn’t move.[/quote]

you can click on a node to “filter” the view of routes for only that node, and click again to come back to the full view

regarding your Route variable, I continue to think somethign is wrong in the format, you may have ManualRoute in wrong format so would be good to check.

[quote=“reneboer, post:639, topic:185570”]Hi amg0,

I got my plug in to register with ALTUI :smiley: (after fixing a minor issue, details below).

Posting the code for others to make use of (mine is actually a bit more complex due to the Harmony plugin setup, but others don’t needs that). One of the tricks is to wait for the ALTUI plugin to be ready. So I have this in my plugin startup.
luup.call_delay(“Harmony_registerWithAltUI”, 10, “”, false)

Note that you must specify all arguments or the action fails (on your log function it seems).

function Harmony_registerWithAltUI()
– Register with ALTUI once it is ready
for k, v in pairs(luup.devices) do
if (v.device_type == “urn:schemas-upnp-org:device:altui:1”) then
if luup.is_ready(k) then
luup.log(“Found ALTUI device “…k…” registering devices.”)
local arguments = {}
arguments[“newDeviceType”] = “urn:schemas-rboer-com:device:Harmony:1”
arguments[“newScriptFile”] = “J_ALTUI_Harmony.js”
arguments[“newDeviceDrawFunc”] = “ALTUI_HarmonyDisplays.drawHarmony”
arguments[“newStyleFunc”] = “”
arguments[“newDeviceIconFunc”] = “”
arguments[“newControlPanelFunc”] = “”
– Main device
luup.call_action(“urn:upnp-org:serviceId:altui1”, “RegisterPlugin”, arguments, k)
else
luup.log(“ALTUI plugin is not yet ready, retry in a bit…”)
luup.call_delay(“Harmony_registerWithAltUI”, 10, “”, false)
end
break
end
end
end

The issue I found is with the registerPlugin functions. The table keys are prefixed with ‘new’ and that is how they end up in the PluginConfig. So line I changed:
for k,v in pairs({ [“ScriptFile”]=newScriptFile,[“DeviceDrawFunc”]=newDeviceDrawFunc,[“StyleFunc”]=newStyleFunc,[“DeviceIconFunc”]=newDeviceIconFunc,[“ControlPanelFunc”]=newControlPanelFunc}) do

I’m sure you will push out a new version to have this fixed in a jiffy :slight_smile:

I’m now going to publish this new version of the Harmony Hub plug in. The very first ALTUI compatible one!!!. Come one akbooer looking for you to be next ;D

Cheers Rene[/quote]

Excellent ! thank you for your help on making a ALTUI compatible plugin ! I referenced your post from the thread msg#1 help page in case others need to do the same. let’s hope we have more and more plugins for ALTUI :slight_smile:

Hi amg0,

I have one more for reading the dutch Smartmeter (electricity and gas usage) but I will be off line after today for a while, so that has to wait.

Also not quite sure how to make an update for the Harmony. As that can have up to 25 buttons on the panel that do fit on the normal Vera UI, but not on the compact ALTUI. May limit it to the first four or so. I’ll think on that.

What I also am not sure on is how the make the tabs work that use JS for UI7 (Settings, Devices, etc. for mine) can that be done? If so how? now it is just crash and burn.

Last question is on icons. For a lot of devices I am not getting the icons, even for standard z-wave ones. For one binary light I see the light bulb, for the next I do not. Any idea?

Cheers Rene

[quote=“reneboer, post:645, topic:185570”]Hi amg0,

I have one more for reading the dutch Smartmeter (electricity and gas usage) but I will be off line after today for a while, so that has to wait.

Also not quite sure how to make an update for the Harmony. As that can have up to 25 buttons on the panel that do fit on the normal Vera UI, but not on the compact ALTUI. May limit it to the first four or so. I’ll think on that.

What I also am not sure on is how the make the tabs work that use JS for UI7 (Settings, Devices, etc. for mine) can that be done? If so how? now it is just crash and burn.

Last question is on icons. For a lot of devices I am not getting the icons, even for standard z-wave ones. For one binary light I see the light bulb, for the next I do not. Any idea?

Cheers Rene[/quote]

for the 25 buttons, either keep the best, or make a cascade button which popups a small window with the 25 buttons ?

The JS tab is allways difficult. possible reasons of failure are:

  • first of all, if possible, only use jquery. if you do use other framework ( like prototype ) I have then to rewrite the source code on the fly ( see _fixScriptPostLoad() in J_ALTUI_uimgr )

  • maybe my simulation layer of Jsonp , or UI7 api , or UI5 api is incomplete , we then need to figure out which api is not correct and try to fix it so that it behaves like on VERA. it is possible but a bit tricky to debug

for the Icons, I also have some issues, it seems my latest UI7 firmware upgrade deleted lots of icons installed by plugins before and either I have to reinstall the plugin or fix the icon by hand. normally ALTUI takes the icon path from the device JSON, but here again, that code is tricky and could be wrong. the best is to get examples, one by one , see which icon is documented in the JSON and see why altui is not showing it ( by looking at the url it tries to open ). ALTUI in debug mode gives more information about it, or you can put a Javascript conditional breakpoint on function _getDeviceIconPath(device) to stop when device.id==nn then step through.
I do not have your devices but maybe I can try your plugin, tell me which plugin it is and I ll try to install it on my test UI5 box

Hi amg0,

Bugger, did find an issue with my Harmony plug in for Multibox support. Due to the setup of my plug in the service urn is unique. This means it only works for the local box, not for the remote one. No idea how the fix that other then manually copy and paste from the remote to the main box.

O well, can’t win em all ::slight_smile:

Cheers Rene

[quote=“amg0, post:646, topic:185570”][quote=“reneboer, post:645, topic:185570”]Hi amg0,

I have one more for reading the dutch Smartmeter (electricity and gas usage) but I will be off line after today for a while, so that has to wait.

Also not quite sure how to make an update for the Harmony. As that can have up to 25 buttons on the panel that do fit on the normal Vera UI, but not on the compact ALTUI. May limit it to the first four or so. I’ll think on that.

What I also am not sure on is how the make the tabs work that use JS for UI7 (Settings, Devices, etc. for mine) can that be done? If so how? now it is just crash and burn.

Last question is on icons. For a lot of devices I am not getting the icons, even for standard z-wave ones. For one binary light I see the light bulb, for the next I do not. Any idea?

Cheers Rene[/quote]

for the 25 buttons, either keep the best, or make a cascade button which popups a small window with the 25 buttons ?

The JS tab is allways difficult. possible reasons of failure are:

  • first of all, if possible, only use jquery. if you do use other framework ( like prototype ) I have then to rewrite the source code on the fly ( see _fixScriptPostLoad() in J_ALTUI_uimgr )

  • maybe my simulation layer of Jsonp , or UI7 api , or UI5 api is incomplete , we then need to figure out which api is not correct and try to fix it so that it behaves like on VERA. it is possible but a bit tricky to debug

for the Icons, I also have some issues, it seems my latest UI7 firmware upgrade deleted lots of icons installed by plugins before and either I have to reinstall the plugin or fix the icon by hand. normally ALTUI takes the icon path from the device JSON, but here again, that code is tricky and could be wrong. the best is to get examples, one by one , see which icon is documented in the JSON and see why altui is not showing it ( by looking at the url it tries to open ). ALTUI in debug mode gives more information about it, or you can put a Javascript conditional breakpoint on function _getDeviceIconPath(device) to stop when device.id==nn then step through.
I do not have your devices but maybe I can try your plugin, tell me which plugin it is and I ll try to install it on my test UI5 box[/quote]
Hi amg0,

On UI7 JS I get that the library Utils is not found. I use that to write error messages to the console in UI7. Maybe I should just change those to console.log but the Utils function is used in MiOS own Philips hue plugin too. I do not know much about JQuery and I’m not using it. If that means I use prototype, no idea ;D. I can see if I can do some JQuery and see what happens as it is not much now. You can find my plugin code here [url=http://forum.micasaverde.com/index.php/topic,28689.0/topicseen.html]http://forum.micasaverde.com/index.php/topic,28689.0/topicseen.html[/url].

Cheers Rene

[quote=“reneboer, post:648, topic:185570”][quote=“amg0, post:646, topic:185570”][quote=“reneboer, post:645, topic:185570”]Hi amg0,

I have one more for reading the dutch Smartmeter (electricity and gas usage) but I will be off line after today for a while, so that has to wait.

Also not quite sure how to make an update for the Harmony. As that can have up to 25 buttons on the panel that do fit on the normal Vera UI, but not on the compact ALTUI. May limit it to the first four or so. I’ll think on that.

What I also am not sure on is how the make the tabs work that use JS for UI7 (Settings, Devices, etc. for mine) can that be done? If so how? now it is just crash and burn.

Last question is on icons. For a lot of devices I am not getting the icons, even for standard z-wave ones. For one binary light I see the light bulb, for the next I do not. Any idea?

Cheers Rene[/quote]

for the 25 buttons, either keep the best, or make a cascade button which popups a small window with the 25 buttons ?

The JS tab is allways difficult. possible reasons of failure are:

  • first of all, if possible, only use jquery. if you do use other framework ( like prototype ) I have then to rewrite the source code on the fly ( see _fixScriptPostLoad() in J_ALTUI_uimgr )

  • maybe my simulation layer of Jsonp , or UI7 api , or UI5 api is incomplete , we then need to figure out which api is not correct and try to fix it so that it behaves like on VERA. it is possible but a bit tricky to debug

for the Icons, I also have some issues, it seems my latest UI7 firmware upgrade deleted lots of icons installed by plugins before and either I have to reinstall the plugin or fix the icon by hand. normally ALTUI takes the icon path from the device JSON, but here again, that code is tricky and could be wrong. the best is to get examples, one by one , see which icon is documented in the JSON and see why altui is not showing it ( by looking at the url it tries to open ). ALTUI in debug mode gives more information about it, or you can put a Javascript conditional breakpoint on function _getDeviceIconPath(device) to stop when device.id==nn then step through.
I do not have your devices but maybe I can try your plugin, tell me which plugin it is and I ll try to install it on my test UI5 box[/quote]
Hi amg0,

On UI7 JS I get that the library Utils is not found. I use that to write error messages to the console in UI7. Maybe I should just change those to console.log but the Utils function is used in MiOS own Philips hue plugin too. I do not know much about JQuery and I’m not using it. If that means I use prototype, no idea ;D. I can see if I can do some JQuery and see what happens as it is not much now. You can find my plugin code here [url=http://forum.micasaverde.com/index.php/topic,28689.0/topicseen.html]http://forum.micasaverde.com/index.php/topic,28689.0/topicseen.html[/url].

Cheers Rene[/quote]

I will take care of Utils with a stub implemented in AltUI UI compatibility layer. can you tell me what this call is supposed to do ? Utils.getLangString("ui7_device_cpanel_details_saved_success","Device details saved successfully.")

I have also seen some calls which are not clear to me. are they documented calls of api7 ? can you tell me what they are and I can try to implement them too.

api.ui.updateDevice(deviceID,ipa,'application.userData.devices['+devicePos+'].ip'); api.ui.startupShowModalLoading();

Lastly, where is myInterface.hideModalLoading() defined ? is this a MCV object or yours ?
I can then give you a version to try to improve compatibility

This is for multi language support and this is for a standard dialogue text I re-use.

[quote=“amg0, post:649, topic:185570”]I have also seen some calls which are not clear to me. are they documented calls of api7 ? can you tell me what they are and I can try to implement them too.

api.ui.updateDevice(deviceID,ipa,'application.userData.devices['+devicePos+'].ip'); api.ui.startupShowModalLoading(); [/quote]
They only documented the little api bit, but not all the other bits they have and they use in their own plugins. So I did some reverse engineering to get to these calls.

myInterface is from MCV and seems to map to api.ui. myInterface did not always work in first UI7 versions so that is why I have some mixed use still.

Any tips are welcome. I can barely find my way in JS, unlike you obviously :wink:

Cheers Rene

This is for multi language support and this is for a standard dialogue text I re-use.

[quote=“amg0, post:649, topic:185570”]I have also seen some calls which are not clear to me. are they documented calls of api7 ? can you tell me what they are and I can try to implement them too.

api.ui.updateDevice(deviceID,ipa,'application.userData.devices['+devicePos+'].ip'); api.ui.startupShowModalLoading(); [/quote]
They only documented the little api bit, but not all the other bits they have and they use in their own plugins. So I did some reverse engineering to get to these calls.

myInterface is from MCV and seems to map to api.ui. myInterface did not always work in first UI7 versions so that is why I have some mixed use still.

Any tips are welcome. I can barely find my way in JS, unlike you obviously :wink:

Cheers Rene[/quote]

I improved some things essentially by adding some api objects that J_HarmonyUI7.js seems to use like these:

// J_Harmony , J_Harmony_UI7.ss
var Utils = ( function (undefined) {
	return {
		logError : function(s) 			{ PageMessage.message(s,"error"); AltuiDebug.debug("Utils.logError: "+s);},
		isValidIp: function(ip) 		{
			var reg = new RegExp('^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(:\\d{1,5})?$', 'i');
			return(reg.test(ip));
		},
		getLangString: function(s1,s2)	{ return _T(s2);}	// returned localized version of the string
	}
})();

var Interface = function (undefined) {
	return {
		showMessagePopup: function(str,code) {  /* TODO what is it */},
		showMessagePopupError: function(msg) {/* TODO what is it */},
		showStartupModalLoading	: function() {	show_loading(); },
		hideModalLoading		: function() {	hide_loading(); }
	}
};
var myInterface = new Interface();

var DOMPurify = (function(undefined) {
	return {
		sanitize: function(str)	{return str;}
	}
})();

I can now see screens ok but I cannot test further as I do not have this device. here is a private ALTUI version with these improvements. I am sure it is not 100% enough but I ll rely on you to try to go further as you have the device with you.

If possible I would suggest a couple of minor changes in the Harmony.js files.

[ul][li]not sure the DOMPurify stuff is needed if you use the Utils.isValidIp() to validate the ip address format.
[/li][/ul]

[li]replace the api.ui by more official calls. The api.ui.updateDevice() is the hard one. it seems to be to set the device attribute “IP” and I did not find an easy way to do that. in AltUI I do a rather complex function ( HAG api ) but I hide it under a simple api : MultiBox.setAttr( device, attribute, value,function(result) ). function is a callback becasue this is an asynchronous call to the HAG http soap api. Either you could use this code if you run with ALTUI ( test for instance the existance of the object MultiBox, or try UI independant , maybe something like the RunLua Action for the HomeAutomationGateway1 and put an LUUP attribute set code in it:

Luup:
http://wiki.micasaverde.com/index.php/Luup_Lua_extensions#function:_attr_set

Javascript code for building the url to call:
var code = “luup.attr_set (‘ip’, ‘192.168.1.4’,theDeviceNumber)”;
var url = _getUrlHead()+‘?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunLua&Code=’+encodeURIComponent(code);

[/li][/list]

This is for multi language support and this is for a standard dialogue text I re-use.

[quote=“amg0, post:649, topic:185570”]I have also seen some calls which are not clear to me. are they documented calls of api7 ? can you tell me what they are and I can try to implement them too.

api.ui.updateDevice(deviceID,ipa,'application.userData.devices['+devicePos+'].ip'); api.ui.startupShowModalLoading(); [/quote]
They only documented the little api bit, but not all the other bits they have and they use in their own plugins. So I did some reverse engineering to get to these calls.

myInterface is from MCV and seems to map to api.ui. myInterface did not always work in first UI7 versions so that is why I have some mixed use still.

Any tips are welcome. I can barely find my way in JS, unlike you obviously :wink:

Cheers Rene[/quote][/quote]

I improved some things essentially by adding some api objects that J_HarmonyUI7.js seems to use like these:

// J_Harmony , J_Harmony_UI7.ss
var Utils = ( function (undefined) {
	return {
		logError : function(s) 			{ PageMessage.message(s,"error"); AltuiDebug.debug("Utils.logError: "+s);},
		isValidIp: function(ip) 		{
			var reg = new RegExp('^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(:\\d{1,5})?$', 'i');
			return(reg.test(ip));
		},
		getLangString: function(s1,s2)	{ return _T(s2);}	// returned localized version of the string
	}
})();

var Interface = function (undefined) {
	return {
		showMessagePopup: function(str,code) {  /* TODO what is it */},
		showMessagePopupError: function(msg) {/* TODO what is it */},
		showStartupModalLoading	: function() {	show_loading(); },
		hideModalLoading		: function() {	hide_loading(); }
	}
};
var myInterface = new Interface();

var DOMPurify = (function(undefined) {
	return {
		sanitize: function(str)	{return str;}
	}
})();

[ul]I can now see screens ok but I cannot test further as I do not have this device. here is a private ALTUI version with these improvements. I am sure it is not 100% enough but I ll rely on you to try to go further as you have the device with you.

If possible I would suggest a couple of minor changes in the Harmony.js files.
[list]
[li]not sure the DOMPurify stuff is needed if you use the Utils.isValidIp() to validate the ip address format.
[/li][/list]
[li]replace the api.ui by more official calls. The api.ui.updateDevice() is the hard one. it seems to be to set the device attribute “IP” and I did not find an easy way to do that. in AltUI I do a rather complex function ( HAG api ) but I hide it under a simple api : MultiBox.setAttr( device, attribute, value,function(result) ). function is a callback becasue this is an asynchronous call to the HAG http soap api. Either you could use this code if you run with ALTUI ( test for instance the existance of the object MultiBox, or try UI independant , maybe something like the RunLua Action for the HomeAutomationGateway1 and put an LUUP attribute set code in it:
[/li][/ul]

Luup:
http://wiki.micasaverde.com/index.php/Luup_Lua_extensions#function:_attr_set

Javascript code for building the url to call:
var code = “luup.attr_set (‘ip’, ‘192.168.1.4’,theDeviceNumber)”;
var url = _getUrlHead()+‘?id=lu_action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=RunLua&Code=’+encodeURIComponent(code);

NOTE: if you add at the first line of your JS files, you can then see them in the debugger
//# sourceURL=J_Harmony_UI7.js

Thanks amg0,

I did try some simple testing and got sort of to the same point you are. Took out the DOMPurify as that threw an error indeed, and found the proper call for setting the ip (api.setDeviceAttribute(deviceID, ‘ip’, ipa):wink:

However, the current values of the variables are not returned by api.getDeviceState trows an ‘options not defined’ error. Not sure about the other api calls you have implemented as I could not get that far in my testing. I guess including the complete vera api file from cmh/js/core.js would be too simple (JS novice talking here ::))

showMessagePopup and showMessagePopupError just show a standard UI7 dialogues with an OK button, the latter with an error icon to boot.

Cheers Rene

[quote=“reneboer, post:653, topic:185570”]Thanks amg0,

I did try some simple testing and got sort of to the same point you are. Took out the DOMPurify as that threw an error indeed, and found the proper call for setting the ip (api.setDeviceAttribute(deviceID, ‘ip’, ipa):wink:

However, the current values of the variables are not returned by api.getDeviceState trows an ‘options not defined’ error. Not sure about the other api calls you have implemented as I could not get that far in my testing. I guess including the complete vera api file from cmh/js/core.js would be too simple (JS novice talking here ::))

showMessagePopup and showMessagePopupError just show a standard UI7 dialogues with an OK button, the latter with an error icon to boot.

Cheers Rene[/quote]

Rene , can you please try this version here attached to see if we go further ?
I cannot include code.js for 2 reasons, first that would not be legal and I want no problem with altui, and second, I cannot read that code they made honestly… really a hodge podge of many inconsistent stuff that I prefer to approach this differently

EDIT: found getDeviceState issue, so this one should work ok

Hi amg0,

That sure works a lot better. The settings page now works. The others to my functions Activities()m Devices(), and DeviceSettings() show the busy spinner but then I get this error on the console: TypeError: response.responseText.evalJSON is not a function.

So I used my next best friend; Google. and found some example using getJSON instead and that works like a charm :smiley: :smiley:

So we are sure getting closer. It does not look too nice yet as the labels in the first column are cut off. But great progress in a day. See what some tutoring by a true expert can bring to the amateur :smiley:

Cheers Rene

[quote=“reneboer, post:655, topic:185570”]Hi amg0,

That sure works a lot better. The settings page now works. The others to my functions Activities()m Devices(), and DeviceSettings() show the busy spinner but then I get this error on the console: TypeError: response.responseText.evalJSON is not a function.

So I used my next best friend; Google. and found some example using getJSON instead and that works like a charm :smiley: :smiley:

So we are sure getting closer. It does not look too nice yet as the labels in the first column are cut off. But great progress in a day. See what some tutoring by a true expert can bring to the amateur :smiley:

Cheers Rene[/quote]

great stuff. we getting closer.
for the table a simple css should do ( providing you use th but should work with td as well)
table.myclass th:nth-child(1){
width:250px;
}

V 0.63.507 510
Mostly a bug fix release

[ul][li]Better OsCommand lua implementation + fix of error message on empty returns( thx Akbooer )[/li]
[li]Scene box layout ( again :frowning: , better use of large screens )[/li]
[li]UI7 api compatibility improvement , adding some part of Utils & myInterface (thx Reneboer )[/li]
[li]v510: room aggregation. filter by room name in case same name appear in multiple controllers. device panel & scene editor restrict room selection list on ambiant controller[/li][/ul]

INSTALL
autoupdate or magic url ?id=action&serviceId=urn:micasaverde-com:serviceId:HomeAutomationGateway1&action=CreatePlugin&PluginNum=8246&Version=28244

Hi amg0,

I now have it working with UI7 but for UI5 using getJSON does not work. Below is my code and the commented out bit works on UI5 and UI7, but not on ALTUI. The (function) bit with getJSON works on UI7 and ALTUI, but not on UI5. Any ideas?

[code] function getInfo(device, sid, what, devid, func, prnt_id) {
var result;
var devnum = (typeof prnt_id != ‘undefined’) ? prnt_id : device;
var tmstmp = new Date().getTime(); // To avoid caching issues, mainly IE.
try {
var requestURL = api.getCommandURL();
} catch (e) {
var requestURL = command_url;
}
// This commented out bit works on UI5, but evalJSON gives an error in ALTUI
// new Ajax.Request(requestURL+‘/data_request’, {
// method: ‘get’,
// parameters: {
// id: ‘lr_’+what+devnum,
// serviceId: sid,
// DeviceNum: device,
// timestamp: tmstmp,
// HID: devid,
// output_format: ‘json’
// },
// onSuccess: function (response) {
// result = response.responseText.evalJSON();
// func(device, result);
// },
// onFailure: function (response) {
// func(device, HAM_ERR_MSG+response.responseText);
// }
// });

// This function works with UI7 and ALTUI, but not with UI5. The request is not even send.
(function() {
$.getJSON(requestURL+‘/data_request’, {
id: ‘lr_’+what+devnum,
serviceId: sid,
DeviceNum: device,
timestamp: tmstmp,
HID: devid,
output_format: ‘json’
})
.done(function(data) {
func(device, data);
})
.fail(function(data) {
func(device, HAM_ERR_MSG+“Failed to get data from Hub.”);
});
})();
}
[/code]

Cheers Rene

[quote=“reneboer, post:658, topic:185570”]Hi amg0,

I now have it working with UI7 but for UI5 using getJSON does not work. Below is my code and the commented out bit works on UI5 and UI7, but not on ALTUI. The (function) bit with getJSON works on UI7 and ALTUI, but not on UI5. Any ideas?

[code] function getInfo(device, sid, what, devid, func, prnt_id) {
var result;
var devnum = (typeof prnt_id != ‘undefined’) ? prnt_id : device;
var tmstmp = new Date().getTime(); // To avoid caching issues, mainly IE.
try {
var requestURL = api.getCommandURL();
} catch (e) {
var requestURL = command_url;
}
// This commented out bit works on UI5, but evalJSON gives an error in ALTUI
// new Ajax.Request(requestURL+‘/data_request’, {
// method: ‘get’,
// parameters: {
// id: ‘lr_’+what+devnum,
// serviceId: sid,
// DeviceNum: device,
// timestamp: tmstmp,
// HID: devid,
// output_format: ‘json’
// },
// onSuccess: function (response) {
// result = response.responseText.evalJSON();
// func(device, result);
// },
// onFailure: function (response) {
// func(device, HAM_ERR_MSG+response.responseText);
// }
// });

// This function works with UI7 and ALTUI, but not with UI5. The request is not even send.
(function() {
$.getJSON(requestURL+‘/data_request’, {
id: ‘lr_’+what+devnum,
serviceId: sid,
DeviceNum: device,
timestamp: tmstmp,
HID: devid,
output_format: ‘json’
})
.done(function(data) {
func(device, data);
})
.fail(function(data) {
func(device, HAM_ERR_MSG+“Failed to get data from Hub.”);
});
})();
}
[/code]

Cheers Rene[/quote]
note sure but I had the case that UI7 returns things in JSON while UI5 is buggy and returns in text, so try to get it with an output format in ‘text/plain’ mime type request then; in the javascript code for the response, use responseText and do a JSON parse of it
var object = JSON.parse( responseText )
but it means you probably need to use Ajax.request or $.ajax() ( personal taste :wink: )

something like

		var jqxhr = jQuery.ajax( 
			{
				url:	url,
				method:	"GET",
				type: "GET",
				dataType: "text",
				cache: 	false,
                                beforeSend: function(xhr) { xhr.overrideMimeType('text/plain'); }
			} )
				.done(function(data, textStatus, jqXHR) {
					if ($.isPlainObject( data ) ==false)
						data=JSON.parse(data);

						if ($.isFunction(cbfunc))
							(cbfunc)(data, textStatus, jqXHR);
				})
				.fail(function(jqXHR, textStatus, errorThrown) {
					if ($.isFunction(cbfunc))
						(cbfunc)(null, textStatus, jqXHR);
				});
		return jqxhr;

I have posted updated files for DataYours and Netatmo devices to display correctly under ALTUI in their respective threads. A later App Store update will, of course, include this too.

fyi… new version will include an accordion based scene editor…