Vera UI bug affects plug-in development

As I was creating a static JSON file for a new device, I noticed that one of the items which I added on tab 2 was not being displayed correctly. Whatever I put in the Nth control of the tab would disappear although controls before or after it would display correctly. After some JavaScript debugging, I realized that the items on tab 2 were being incorrectly updated from the corresponding items in tab 0. Control N on tab 0 turned out to be a variable (which was blank) and was clobbering the item in Tab 2.

I created a patch to fix this problem. (attached)

This bug exists in both Firmware 1.5.622 as well as the older 1.5.408 firmware.
I filed a bug regarding this issue with Mi Casa Verde: [url=http://bugs.micasaverde.com/view.php?id=3018]http://bugs.micasaverde.com/view.php?id=3018[/url]

[code]#diff -C3 /mios/www/cmh/js/ui5/main.js /www/cmh/js/ui5/main.js
*** /mios/www/cmh/js/ui5/main.js 2013-03-07 05:18:39.000000000 -0800
— /www/cmh/js/ui5/main.js 2013-06-03 07:34:16.235900000 -0700


*** 457,462 ****
— 457,463 ----
}
try {
var device = jsonp.get_device_by_id(newObj[0].id);

  •         var tab_id = newObj.length > 1 ? newObj[1] : 0;
            {// redraw the battery level
                setDOMDeviceBatteryLevel(newObj[0].id);
            }
    

*** 471,477 ****
}

                 var device_type = device.device_type.split(":")[device.device_type.split(":").length-2];

! var controls = jsonp.get_device_definition(device.device_type).Tabs[0].Control;
var device_def = jsonp.get_device_definition(device.device_type);
if(newObj[0].tooltip.display == 1){
if(newObj[0].tooltip.tag2!=“undefined” && newObj[0].tooltip.tag2!=undefined ){
— 472,478 ----
}

                 var device_type = device.device_type.split(":")[device.device_type.split(":").length-2];

! var controls = jsonp.get_device_definition(device.device_type).Tabs[tab_id].Control;
var device_def = jsonp.get_device_definition(device.device_type);
if(newObj[0].tooltip.display == 1){
if(newObj[0].tooltip.tag2!=“undefined” && newObj[0].tooltip.tag2!=undefined ){

#diff -C3 /mios/www/cmh/js/ui5/devices.js /www/cmh/js/ui5/devices.js
*** /mios/www/cmh/js/ui5/devices.js 2013-03-07 05:19:03.000000000 -0800
— /www/cmh/js/ui5/devices.js 2013-06-03 07:41:26.883900000 -0700


*** 498,504 ****
//if(tab_id==0){
for(var i=0;i<jsonp.lu.devices.length;i++){
if(jsonp.lu.devices[i].id==o.id){
! jsonp.fireEvent(“on_device_status_changed”,[jsonp.lu.devices[i]]);
}
}
//}
— 498,504 ----
//if(tab_id==0){
for(var i=0;i<jsonp.lu.devices.length;i++){
if(jsonp.lu.devices[i].id==o.id){
! jsonp.fireEvent(“on_device_status_changed”,[jsonp.lu.devices[i],tab_id]);
}
}
//}[/code]

To apply this patch, use a tool such as WinSCP available here: http://winscp.net Log in with user ID root and the password is on the bottom of your Vera. Navigate to /www/cmh/js/ui5 and rename devices.js to devices.js.original. Also rename main.js to main.js.original. Then unzip the attached files and copy the two new .js files to the directory in Vera.

Unfortunately, this is the type of bug which we will need to work around until MCV rolls out a new firmware update which we can all rely on. In the meantime, we should all at least be aware of this glitch.

Thank you!