How to expand/upgrade existing builtin widgets?

How can I use this code (original widged):

and reimport it as JSON to make my own variant of the standard button widget?

I find it hard to start from scratch to make custom widget and in essence, I just want to change a few things in the original widget and get improved widget “button2”.

First: use the latest repository this one seems to be outdated.
Then I think you have at least two posibllites:
a) get the source; modify the source and build your own version of org.openhab.ui.habpanel-2.5.7.jar
b) unzip org.openhab.ui.habpanel-2.5.7.jar ( by using e.g. 7z ); edit the files you want to modify;
zip the files again to get a modified org.openhab.ui.habpanel-2.5.7.jar file;
in both cases you need to replace the existing org.openhab.ui.habpanel-2.5.7.jar file

  • be aware that by doing this with updates your modified version will be overwritten
  • create a backup of the original file to be able to restore it in case of problems

You don’t need to compile a jar (that would make it far harder to share with other people) or open one up. It can be useful to peak into the source code here which if your using version 2.x of Openhab the code is archived as Version 3.x is being worked on:

How to reuse and extend existing widgets is talked about in the linked post below. Other examples can be found if you search the forum using parts of the code that help ensure only posted examples will get a hit.

I would do a search for <widget-button ng-model= as an example and you should get people who have posted questions on the button widget and given an example…

I did it recently and it was as simple as inserting the widget code, setting any configs to hard coded defaults or creating the config items from scratch in the editor. I am in the middle of making a new button and will look to editing the wiki post which is below.

Examples can be looked at by looking at other widgets people have created as well and uploaded to the gallery or this forum.

1 Like