Developing OH 3.0 Bindings

Tags: #<Tag:0x00007f433cf2b648> #<Tag:0x00007f433cf2b580>

Is there already guidance who to move to OH3 Binding Development

  • Correct setup of the IDE (Eclipse)
  • Conversion of bindings
  • What’s new?
  • What’s deprecated?
  • Formal requirements (like: get rid of Apache Commons etc.)

I saw a post discussing the bindings conversion, but can’t find it again (@hilbrand?)

2 Likes

Thanks, that was what I‘m looking for👍

I’m trying to move my development from 2.5.x to 3.0. When installing Eclipse after selecting 3.0 for development, addons, and core, I’m getting the following exception on the task https://github.com/openhab/openhab-addons.git (master).

I’m not sure how to resolve this. Do I need to delete the existing fork that I was using for 2.5.x, then fork openhab-addons?

Adding push URI: https://github.com/mhilbush/openhab-addons.git
Creating local branch master
java.lang.Exception: org.eclipse.jgit.api.errors.RefNotFoundException: Ref refs/remotes/origin/master cannot be resolved
  at org.eclipse.oomph.setup.git.impl.GitCloneTaskImpl.perform(GitCloneTaskImpl.java:989)
  at org.eclipse.oomph.setup.internal.core.SetupTaskPerformer.doPerformNeededSetupTasks(SetupTaskPerformer.java:3828)
  at org.eclipse.oomph.setup.internal.core.SetupTaskPerformer.access$1(SetupTaskPerformer.java:3771)
  at org.eclipse.oomph.setup.internal.core.SetupTaskPerformer$WorkspaceUtil$1.run(SetupTaskPerformer.java:5137)

It might be outdated, the master branch was renamed to main, that’s what @Kai already posted.

Hmm. Then how will that work if the Eclipse installer is expecting master?

I guess Eclipse installer has to be updated.

Yes the eclipse setup needs to be updated. What you can do is just install development, that still uses master. And after eclipse has finished then on the command line go to the git directory and:

git clone git@github.com:<your GitHub id>/openhab-addons.git

(or use the http version).

  • Note: If you have an old fork it might still be named openhab2-addons. You can rename that on GitHub (preferable before you clone)

To get the new main from the openhab-addons repo, followed by:

git remote add upstream git@github.com:openhab/openhab-addons.git
git fetch upstream

Make sure to install with with Java 11 and Java 11 selected during setup.

5 Likes

Thanks @hilbrand. I’ll give that a try.

@hilbrand That worked. I was able to get Eclipse installed using openHAB Development and openHAB Core. I then cloned my openhab-addons repo and fetched the main branch from upstream. I imported a few bindings. So far so good.

I tried building using maven, but ran into an issue. Any idea how to resolve this?

mark@S5 MINGW64 ~/openhab3/git/openhab-addons/bundles/org.openhab.binding.bigassfan (main)
$ java -version
openjdk version "11.0.8" 2020-07-14
OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.8+10)
OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.8+10, mixed mode)

mark@S5 MINGW64 ~/openhab3/git/openhab-addons/bundles/org.openhab.binding.bigassfan (main)
$ mvn install
[INFO] Scanning for projects...
[WARNING] Error injecting: org.openhab.tools.analysis.report.SummaryReportLifecycleParticipant
java.lang.TypeNotPresentException: Type org.openhab.tools.analysis.report.SummaryReportLifecycleParticipant not present
    at org.eclipse.sisu.space.URLClassSpace.loadClass (URLClassSpace.java:147)
    at org.eclipse.sisu.space.NamedClass.load (NamedClass.java:46)
    at org.eclipse.sisu.space.AbstractDeferredClass.get (AbstractDeferredClass.java:48)
    at com.google.inject.internal.ProviderInternalFactory.provision (ProviderInternalFactory.java:85)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision (InternalFactoryToInitializableAdapter.java:57)
    at com.google.inject.internal.ProviderInternalFactory$1.call (ProviderInternalFactory.java:66)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision (ProvisionListenerStackCallback.java:112)
    at org.eclipse.sisu.bean.BeanScheduler$CycleActivator.onProvision (BeanScheduler.java:230)
    at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision (ProvisionListenerStackCallback.java:120)
    at com.google.inject.internal.ProvisionListenerStackCallback.provision (ProvisionListenerStackCallback.java:66)
    at com.google.inject.internal.ProviderInternalFactory.circularGet (ProviderInternalFactory.java:61)
    at com.google.inject.internal.InternalFactoryToInitializableAdapter.get (InternalFactoryToInitializableAdapter.java:47)
[[snip]]

BTW, I tried building a bundle in openHAB core, and I get the same error.

Here’s the last part of the exception. Do I need a different revision of Java 11, or perhaps something other than OpenJDK?

Caused by: java.lang.UnsupportedClassVersionError: org/openhab/tools/analysis/report/SummaryReportLifecycleParticipant has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
    at java.lang.ClassLoader.defineClass1 (Native Method)
    at java.lang.ClassLoader.defineClass (ClassLoader.java:763)
    at java.security.SecureClassLoader.defineClass (SecureClassLoader.java:142)
    at java.net.URLClassLoader.defineClass (URLClassLoader.java:467)
    at java.net.URLClassLoader.access$100 (URLClassLoader.java:73)
    at java.net.URLClassLoader$1.run (URLClassLoader.java:368)
    at java.net.URLClassLoader$1.run (URLClassLoader.java:362)

Edit:
Ok, even though I installed Java 11, my JAVA_HOME is still pointing to Java 8. I’ll try to resolve that and see if it fixes the problem.

Edit 2:
Looks like that was the issue. All good now.

1 Like

Hi @hilbrand
I installed Java SE 11, set Win10 @JAVA_HOME@ to JDK 11, checked mvn runs on Java 11, installed Eclipse 2020-09 selecting Java 11 and just Development, waited Eclipse finish install, then cloned my fork of openhab-addons, set remote upstream+fetched it and then moved to main branch.
Then added astro and openwebnet bindings to demo.app pom.xml, added astro and openwebnet bundles to app.bndrun. Then when I click resolve I get this error:

    Resolution failed. Capabilities satisfying the following requirements could not be found:
        [<<INITIAL>>]
          ⇒ osgi.identity: (osgi.identity=openwebnet4j)
              ⇒ [openwebnet4j version=0.3.0]
                  ⇒ osgi.wiring.package: (&(osgi.wiring.package=gnu.io)(&(version>=3.15.0)(!(version>=4.0.0))))
        [jakarta.activation-api version=1.2.1]
          ⇒ osgi.wiring.package: (&(osgi.wiring.package=com.sun.activation.registries))

It looks like openwebnet4j (required by openwebnet) it looks for gnu.io, but it cannot be resolved by bnd.

Any hint?

EDIT: I also wrongly added openwebnet4j bundle to app.bndrun. If remove it, then resolve completes correctly requiring nrjavaserial 5.2.1 which provides gnu.io.

I just pulled the latest snapshot of openHAB3 to continue development of our Bosch binding (https://github.com/stefan-kaestle/openhab2-addons) There seems to be a new login mechanism in place. Is there some information somewhere how to create an administrator account or is there a default administrator account I can use to access the settings via the UI? Previously it was not necessary to login to add/update things, items, etc.

First access to the new UI will ask you to setup your admin account.

Thanks for the information @hmerk!

The problem was probably that I reused the userdata folder from the previous version instead of clearing it. I will try it with a clean installation.