Upgrading Plugins for UI6

I though I would log the steps I needed to perform to upgrade my Plugins to simultaneously support UI5 and UI6.
[hr]
Issue #1 - Local Icons are now in /www/cmh_ui6/skins/default/icons

My Solution was to release a script (Make Sure it’s unique):
va-install.sh
Make sure you do not compress or encrypt it when saving in App Store.

The file contains the following:

if [[ -e /www/cmh ]]; then
  cd /www/cmh/skins/default/icons/
  ln -s /etc/cmh-ludl/VeraAlerts-48.png 
fi
if [[ -e /www/cmh_ui6 ]]; then
  cd /www/cmh_ui6/skins/default/icons/
  ln -s /etc/cmh-ludl/VeraAlerts-48.png 
fi

Then I added the following to the plugin init:

      os.execute("/bin/sh /etc/cmh-ludl/va-install.sh")
      os.remove("/etc/cmh-ludl/va-install.sh")

This script will have to evolve over time … I am going to release my icons to the /etc/cmh-ludl area. This also makes the APP-Store publishing simpler.

That’s a good idea, I will do the same for the Sonos plugin.
But one problem you might forget is that files will be lzo compressed when uploaded in /etc/cmh-ludl ?

Are you going to bug that against them?

There’s really no need to change the location of the Icons directory across versions, at least when that same directory is “shared” with user/plugin code (until that’s modularized/formalized)

We had a similar(ish) set of changes that were done in UI5 that they backed out, based upon the compatibility feedback.

ie. Plugins should work, without change, even if it’s in some sort of degraded/compatibility mode.

There were a few things that needed to be done, but in general they would “co-exist” (UI4/UI5 at the time) for a single-stream, cross-release, codebase without hacks.

Without providing at least “one release” compatibility, they tend to lose plugins during the transition.

@EveryOne
My initial evaluation is … it’s not worth upgrading to UI6. I think this will be a good platform for developers to get the kinks out of the software on the way to UI7.
They have a beginning of a new UI … but it’s so thin that it’s not very useful. For the most part you end up clicking and Advanced tab which takes you back to a Ui5 looking interface … but there are changes there as well that effect developers.

For those that want to jump too UI6 … just be patient with the developers. There are a number of changes and it will take time to get these sorted out.

@lolodomo
I use the App store for install … so you have control over compression and encryption.
Feel free to add your comments here … Or I can rename my thread.

@guessed
I think I will just document for now … And then as a group we can decide how/what to follow up to MCV. I think we should get a better understanding of all the changes and have a single coherent request as opposed to a bunch of fragmented and possibly conflicting requests.

Issue #2 - They now use jQuery 1.6 for UI6, and it looks like they use jQuery 1.9 for the new part of UI6 (beginning of UI7).

The JQuery semantics have changed a lot between jQuery 1.5 (used in UI5) and jQuery 1.6/1.9 (Used UI6+). The good thing is that jQuery mostly stabilized with the 1.6 release. For me I do not see a way to have a single implementation for UI5 and UI6. I am hopeful that I will not have to change much for UI7 … but there is not enough of the UI7 interface to decide. So my strategy is to release separate .js files … one fore UI5 and one for UI6. Finding and fixing the JS was pretty straight forward … just search for $( and fixup the changed semantics. It was hard for me to learn jQuery 1.5 semantics in the first place … since I never used that old a version before … So the upgrade was pretty mechanical.

I will add the appropriate logic to my va-init.sh script

cd /etc/cmh-ludl
if [[ -e /www/cmh_ui6 ]]; then
  ln -s J_VeraAlert-UI6.js  J_VeraAlert.js
else
  ln -s J_VeraAlert-UI5.js  J_VeraAlert.js
fi

Here you can replace the .js with the .js.lzo or js.lzoenc as appropriate for your install.

More urgently, they removed prototype.js entirely in UI6 (or so I am told). That’s a good thing, but it means I’ve got to update my plugins.

Here is my effort to remove prototype.js from the Caddx plugin and to use straight jQuery. It runs fine on my UI5 Vera with jQuery 1.5.

The intersection of jQuery 1.5 and 1.6 that has the same semantics is IMO big enough to write (somewhat convoluted) JavaScript that’ll work on UI5 and UI6.

I assumed the difference in semantics for $ was JQuery 1.5 … which was already and old version and hard to find documentation for … I never looked close enough to notice that this was from prototype.js … I was already familiar with a newer Version of JQuery when I first looked at Vera’s code.

So I guess I changed from prototype.js semantics to pure JQuery semantics.
Maybe I can have one version … But I hate not using $ … that’s how I learned JQuery … and I am an old dog :wink:

Issue #3 - No way to test downloads from the AppStore prior to release with UI6.

When you login to the App Store … it will only take UI5 credentials … and not UI6 credentials.
Oh well I guess I will release and hope for the best :slight_smile:

Regarding using ${} in Javascript, is it something that has disappeared in JQuery 1.6 or is it just something not usable in UI6 because Micasaverde has forgotten something ?
In the second case, we could simply ask and wait for an UI6 update that would restore possibility to use ${} in Javascript (keeping JQuery 1.6).

[quote=“lolodomo, post:9, topic:179375”]Regarding using ${} in Javascript, is it something that has disappeared in JQuery 1.6 or is it just something not usable in UI6 because Micasaverde has forgotten something ?
In the second case, we could simply ask and wait for an UI6 update that would restore possibility to use ${} in Javascript (keeping JQuery 1.6).[/quote]

Noone ?

Except JavaScript; are there other things that have changed (lua side) ?

Some other Prototype-isms that I found in my code, and how to turn them to jQuery:

escapeHTML() is gone. Instead write your own function.

# old: ... zoneName.escapeHTML() ...

[code]#new:
var entityMap = {
“&”: “&”,
“<”: “<”,
“>”: “>”,
‘"’: ‘"’,
“'”: ‘'’,
“/”: ‘/’
};
function escapeHtml(string) {
return String(string).replace(/[&<>"'/]/g, function (s) {
return entityMap[s];
});
}

… escapeHtml(zoneName) …
[/code]

.findAll() is gone. Use .grep():

#old: return jsonp.ud.devices.findAll(function(d) { ... });

#new: return jQuery.grep(jsonp.ud.devices, function(d) { ... });

.select() is gone. Use .find():

#old: if (actionCell.select('.caddx_useraction_setpin').length == 0)

#new: if (jQuery(actionCell).find('.caddx_useraction_setpin').length == 0)

.invoke() is gone. Refactor to use .each():

#old: button.parentNode.parentNode.select('input').invoke('disable');

#new: jQuery(button.parentNode.parentNode).find('input').each(function(i, n) {n.disabled = true;});

.inject() is gone. Refactor to use .each():

#old: htmlResult += serialDevices.inject("", function(htmlResult, d) { ... return htmlResult; });

#new: jQuery.each(serialDevices, function(i, d) { ... htmlResult += ... });

.innerHTML is gone. Use html():

#old: element.innerHTML = '<p>Press Save to continue</p>';

#new: element.html('<p>Press Save to continue</p>');

lolodomo: The $ variable bound to the same variable as jQuery in Vera UI6. If you wanted to abandon UI5 users you could write JavaScript that uses $ for jQuery. I haven’t found any significant differences in LuaUPnP yet.

Any idea what will happen with UI7 ?
I mean, is there a chance that these JavaScript changes make our plugins compatible with UI7 too ?

[quote=“lolodomo, post:12, topic:179375”]Any idea what will happen with UI7 ?
I mean, is there a chance that these JavaScript changes make our plugins compatible with UI7 too ?[/quote]

The changes needed for UI6 should work with UI7. Think of UI6 as a cross between UI5 and UI7.

  • Garrett

My gut feeling is that if you make your plugin UI6 compatible then you get most of the way to UI7 compatibility for free. jQuery is most likely going to be where MCV stays.

Existing changes to UI6 have people getting things to work in the Advanced (Or should it be called Antiquated) tab of UI6.

I image that in UI7 people will need to make changes so that their UI is available on the main dashboard.

[quote=“RichardTSchaefer, post:15, topic:179375”]Existing changes to UI6 have people getting things to work in the Advanced (Or should it be called Antiquated) tab of UI6.

I image that in UI7 people will need to make changes so that their UI is available on the main dashboard.[/quote]

Richard,

It seemed to me that the UI6 beta release was not widely know to the developers on this forum. And now, MCV is getting ready to release UI7 in a broad beta release. Have they been in communication with folk like you in order to get your apps/plugins ready, or will it be coming completely fresh to you too?

Just curious. I’m one of the folks not that eager to move up. I have things filed in quite nicely and I prefer to focus on doing more than redoing old.

PS thanks again for PLEG, and the continued improvements.

I do not know if they been in contact with other app developers, but they have been with the beta members.

  • Garrett