Templated addon?


Not sure if something like this has been discussed, is feasible or is just a bad idea? :slight_smile:

Is there / could there be a way to create a “templated binding” which would make building bindings or widgets easier? Like making HABPanel widgets.

The example I have in my head is my train-departures time. I built it with a rule, it uses HTTP API, relies on the user manually creating items etc.

Is it conceivable that we could have a binding which will allow me to plumb together and export as a template / widget. Others can import this which, at time of import, will create the things and items needed.

I know there is effort going into the jython shareable libraries for new rules and, while this is massively helpful, it still requires someone to have, in some way, a head for code.
If this thought process was done to allow them to import and then it becomes a GUI clicky-click addon which many can use.

This would also lend itself to a more indexed method for people to browse and find functionality within the ecosystem.

Not sure if I am articulating my point very well?


If you install the new rule engine, you can create rules through Paper UI. You also have an option to create a rule from a template.

This functionality has been around for a LONG time, but I do not think anyone from the comminuty has has created documentation for it yet. If you have the Eclipse IoT Marketplace installed, there is an option for rule templates.

You can also search the Eclipse IoT Marketplace for rule templates, which should still be compatible with OH. A new marketplace (ExtensionService) for openHAB is needed and is definitely an area that will get attention in OH3.0. This is a huge effort, but the ability to share and collaborate on automation through a similar marketplace will be a massive improvement over copy/paste in the forum!

My intent is to include all of the community contributions included in the helper library repository into such a marketplace. The libraries will be included in the Jython bundle or possibly separately, and the scripts will be rule templates. There are a lot of details yet to be worked out!


Sorry, a bit of misdirection there about the rules and the gui option for rules. I’m not trying to share rules (although that is something that would work in some case) but rather, what you said here:

This is exactly what is needed :slight_smile:
It needs to be, to “install” and use, almost as simple as adding a new addon. Something along the lines of "drop this zip file into the “install” director and something magic happens.

Your idea of improving the collaboration needs to include setting up the things, items, rules etc
To create, there should be an “export” function which creates something like a yaml file which can be shared.

It will serve two purposes:

  • Let the less code-headed person get more involved and improved automations
  • Give a starting point for those who want to fiddle with it and plumb it into other elements of their system

For one of my sites I use Xenforo as a forum platform. In there I can create a module called “crispin’s module”, make config changes, add new fields etc and when done, click on the export-module button. An xml file is then created which is all the other person needs.

This is what I was describing as currently available through the Eclipse IoT Marketplace ExtensionService. One specific for OH will be setup too.

I think that will come in a much later phase. Creating Items, Things, dependencies on bindings, even specific system configurations, etc. through a template is all very complex. We need to start small and get in some iterations.

However, this is possible now using the Jython HLs. The OWM script creates the Items for you. I will be adding a PR for a core.things module that can be used for creating Things and includes functionality similar to Simple Mode, where the Items can be created for all of the Channels of the Thing.

The ability to export a template from an existing rule does not exist yet, but it’s pretty easy to do by hand. I may have posted about how to do this already, but I also have a draft tutorial post on how to use templates that will go out one of these days. My plan is to release several rule templates after the Jython bundle PR is approved.

From another topic…

To elaborate on Scott’s answer, with the NGRE, it is possible to create Rules that:

  • install like a binding
  • create the Items it needs automatically for you
  • are configured like a binding
  • no need to actually edit or modify the code to use it; it’s a “GUI clicky-click addon”

For something like this, I think a Rule Template would be more appropriate than a binding. It would be easier to create and ultimately less work for users to use.

That’s the goal. You would search the list of Rules like you do for Add-ons, read the docs, just like you do for add-ons, and “install” the Rules just like you install add-ons. It’ll be all GUI clicky-click with forms to configure.

Already possible and there are several Community library submissions that do this (e.g. see the OWM Forecast library).

Alternatively, in some cases, it make more sense to let the user define their own Items and just configure the Rules to use those, which is also supported.

Why export/import? Why not “Publish to a Marketplace” where the Rule can just be discovered and installed through the openHAB UI?

But, for the record, you can export/import already, only the UI isn’t there yet. But you can do it through the REST API. the format is JSON.

At this point, your best bet is probably to submit them as a Community library. Or, if you are adventurous, you can try to figure out how to hand roll the JSON necessary to build a Rule Template by hand.

EDIT: Oops, I thought I was responding to Crispin, not you. Never mind. You know what you are doing. :slight_smile:

tl;dr, what you are asking for either already exists or already is the goal.

1 Like

Thanks both. I appreciate that having something that easily supports sharing is going to be a bigger piece of work and, as @5iver fiver said, iterative.

Are you referring to the gallery? That is exactly the idea. I’ve got a couple of widgets in there. I can’t help but feel though that there is more out there than is submitted; why are others not submitting their great ideas?

I’ll take a look at the other bits you mentioned and see if I can use it on some of the automations I have.

I’ve no doubt that the above is on the roadmap; it’s going to be awesome watching this platform grow. :smiley:

No, not the HABPanel Gallery.


and there is a backlog of PRs awaiting review and approval with more.

There are several submitting all sorts of good ideas. And as more and more people start to transition to scripted automation we will find more and more submissions. Personally, I’ve mostly focused on providing building blocks rather than fully fledged capabilities so you will find stuff like various design patterns from m so far.

Any idea if 3.0 is targeted for 6 months from now or 12 months? I understand this is the version after 2.5 according to Kai’s blog posting.

It’s WAY too soon to tell! You’d also need to ask a maintainer, who are working through the details. The list of features for OH 3.0 is still being built, but the maintainers have a growing backlog. The release will occur after these features are complete.

(only members of the OH organization in GH will have access to those links)

1 Like