Guide: Binding development changes for openHAB 3 (from 2.5.x)

That is normal and nothing you are doing wrong if you can see the binding when you try and add a thing from the inbox. See here where I raised it as an issue which I still believe this to be although very minor once your aware of it.

[Main UI] Installed bindings listed in UI do not include JAR files from the addons folder. · Issue #386 · openhab/openhab-webui (github.com)

@dmazan
If you want someone to look at it, then create a PR for it and mark it as a WIP work in progress. My first thought is it may be a dependency issue but it could be other things.

1 Like

This so needs changing (I think there’s discussion somewhere about highlighting them or something). So confusing for new users. See it again and again.

Use bundle:list on the OH console to see if the binding became active (or listed at all). If it‘s not active try bundle:start, this will bring up an error if the binding has a dependency, which can not be resolved. Compared to regular installed bindings through the UI the framework doesn‘t auto-resolve and install dependent components for those in the addons folder. You need to do this manually.

And yes, it‘s confusing for new users, but also for developers (from my poc PaperUI was more dev friendly :-))

1 Like

Just to make clear, if you are looking at PaperUI, you are looking at openHAB 2.x.
An openHAB 3 binding would not work in openHAB 2…

Either this is a typo, or it is definitely wrong.

Thanks for all of the good feedback. To clarify a couple of points:

  1. The ISY binding bundle is fully resolved and active when viewed in the console with bundle:list.
  2. I shouldn’t have said “Paper UI”. It isn’t showing up on the Bindings tab in the OpenHAB 3 Settings administrative interface, although I now understand that is normal for a bundle in the addons directory.

Maybe I am confused regarding the Inbox. When I go to the Things tab on the Settings administrative interface and click the “plus” button, I do not have the new ISY binding listed as a binding for which I can create a new Thing. Is that the “Inbox” or is it somewhere else?

I am wondering whether I have correctly identified the binding entry points. Does the fact that it shows as “active” indicate that the handlers have been properly registered or just that the bundle was able to be loaded?

If I don’t track it down I’ll create a PR but I at least want to give it a good shot first.

2 Likes

You can push your binding to your fork ans post the link here.
This will allow us to have a look at your code before creating a PR.

Here you go: https://github.com/dmazan/openhab-addons/tree/isy-binding-3.1.0.

Not much to it; just the changes recommended in this post and some fumbling around on my part to make maven happy. Appreciate any feedbacl.

1 Like

If you need dependencies you should build a kar file. This will take care of installing dependencies.

In general when a binding is only active, but you can’t add any things it means openHAB could load the jar, but it could not read the openHAB configuration. Looking at your code you removed the osgi XML files but didn’t replace them with the required annotations. It’s not these files are not needed, but that it’s done via annotations. Also your OH-INF binding XML files are in the wrong place. They should be in src/main/resources/ These 2 issues mean no services of your binding are started and openHAB can’t read your binding configuration, which results in no visible things to add.

2 Likes

Thank you for taking a look. I could have stared at it all day and not noticed those two problems. Moving the OH-INF to the correct location took care of OpenHAB finding the binding. Adding the Component annotation to the HandlerFactory took care of OSGI. It seems to be working now although I’m still testing.

I think the only dependency is org.openhab.core.config.discovery.upnp. At least that’s the only think I had to manually add. Is there a good example of a kar file used with OpenHab?

make sure to define the dependency in src/main/feature/feature.xml, example:

<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.magentatv-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
	<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features
	</repository>

	<feature name="openhab-binding-magentatv" description="MagentaTV Binding" version="${project.version}">
		<feature>openhab-runtime-base</feature>
		<feature>openhab-transport-upnp</feature>
		<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.magentatv/${project.version}</bundle>
	</feature>
</features>

You could use

mvn clean install -pl :org.openhab.binding.<your binding> karaf:kar

command to kreate a .kar file with included dependencies and put it into addons folder.

1 Like

Perfect, thanks. I’ll use that binding as an example to clean up a bunch of things. What an excellent community.

agreed