Any working tutorial for binding development?

Hi All,
I wanted to try out some binding debugging/development. After some hours of frustration I’m writing to you.

https://www.youtube.com/watch?v=o2QjCGdZl7s
Outdated, there is no eclipse run configuration

https://www.openhab.org/docs/developer/ide/eclipse.html
Without additional bindings I can start app.bndrun, but an empty page asks for HTTP credentials. I tried with and without addons enabled at eclipse setup.

https://www.openhab.org/docs/developer/ide/eclipse.html
With additional binding (e.g. Astro) I can’t start app.bndrun because ‘org.eclipse.smarthome.core’ is missing (adding it as dependency does not help)

https://www.openhab.org/docs/developer/ide/intellij.html
Can’t install any UIs, dashboard dies after first access

https://community.openhab.org/t/howto-setup-intellij-for-binding-development/87135
404 on root path

There are some topics in the community about development, but the ideas there did not help (or I misunderstood the solutions). My last Eclipse usage was two years ago and it feels like I’ve never seen it before :sweat_smile:

Additional information:

  • OS X 10.15.2
  • openjdk version “1.8.0_232” (Amazon Coretto)
  • Apache Maven 3.6.3

Is there any working tutorial out there?

Hey @darkspirit510, I wrote the IntelliJ tutorial (so I can only speak for IntelliJ) only a couple of weeks ago when I was in the same situation like you (actually without any tutoriol for IntelliJ) - so I’m really interested in getting this to work!
Can you be a little bit more precise on what the problem is?

Actually this step is just installing the official openhab distribution on your machine (no development specific steps about it) - so this really should work, otherwise there would be tons of complaints.

I’d suggest you pick a IDE you’re familiar with and open a thread for any specific problems if you have trouble getting it to run - this collective thread here will be confusing.

The second IntelliJ link you posted was just the first version I posted in the forum before creating a PR for the official docs (the first link). The forum version included steps for building the openhab distribution locally in the IDE, which is not necessary anymore since version 2.5 was released officially.

Hi @pravussum

I know that this should be a simple “download two files, extract one, place the other in the correct directory”-task. I can see the typical selection overview of which mode to setup your openhab (expect, basic, etc).

I’m familar with intellij, but don’t have problems using Eclipse. I just can’t get it running and would like to understand why - no matter which IDE. Maybe it’s my mac (just switched from ubuntu a month ago).

Edit: I’ll start over from scratch this evening and post my results. I’ll try things on a windows machine, too. Maybe I just misconfigured my device.

The documentation for Eclipse correct. However due to the start of version 3.0 you need to do 2 things:

  1. in openhab-distro: git checkout 2.5.x and in the openhab-addons you need to do the same.
  2. It has PaperUI installed in the demo, but you need to go to http://localhost:8080/paperui/index.html Opening the root will give you the login dialog.
1 Like

Wow, thank you! I could checkout the branches, start the backend and found the bindings. I can start the backend now - but I can’t add bindings. I started with an existing one (in this case Tankerkoenig). Another hint for me? :relaxed:

PS: Did I just attend with bad timing or should this be added to the tutorial?


Edit: Problem solved. Had to manually copy the compiled binding to addons directory. Working now. Thank you!

It’s both unfortunate timing and it should be added to the documentation (I’m working on that). However you should be able to add bindings to the demo app as described in the openHAB eclipse ide documentation, (See also animation) without having to add the binding to the addons folder. If you only want to run the binding it’s not necessary to first import the binding to eclipse before following the steps to add the binding to the demo app.

1 Like

Hi, I’m running into the same issue. Following the Eclipse IDE tutorial (from https://www.openhab.org/docs/developer/ide/eclipse.html ), the result is that the binding does not show up in paper UI. Any ideas on how to resolve it? Could it have to do with the version being used in the POM dependency?

It can be anything. Without specific details it;s hard to tell what the problem is… If you tried an existing binding and followed all the steps it should work.

I have found the reason, or at least part of it. I’m not using the Oracle JDK 8, but OpenJDK 11. It seems the reflection / injection needed for the add-ons is dependent on the runtime execution environment. Changing in the Core Runtime section of the app.bndrun the Execution Env from JavaSE-1.8 to JavaSE-11 makes it work. You still need to add the source to the source path of Eclipse, in order for the debugger to find the appropriate source. It seems that by default the workspace is not added in the source path.

I have one question which oracle jdk8 x64 or x86 should I use for developing?

I use Azul Zulu 8 x64 which is absolutely fine.

What is better oracle java jdk or Azul Zulu???

Don‘t know, but I don‘t like Oracles license policy.

Besides the fact Oracle is not free unless your a developer and Zulu is opensource and free to use, you are always best to stick with what the bulk of the users are installing. Openhabian installs Zulu by default (docs recommend Zulu) so you have tons of users reporting bugs that get fixed under that Java and a lot of developers also testing before code is released.

Use whatever you want as they all should work, but there is something to be said about sticking to what the bulk of users have. This goes for any software.

Another question is does it make sense to develop now an add-on or wait for OH3 release?.

My opinion is it would be better to do it now under 2.5.x since the bugs are all known so any issues you will know if it is your code or not causing the issues. Documentation is also in a good state. If you setup a system with the newer Java 11 and Openhab 2.5.x to test with, it should be pretty simple to change the binding to 3.x if it works with Java 11.

Hello I get this error during execute the cmd line command for creating a new binding how to slolve this? where do i need to add this to my path variable?? i am using azul jdk8 on win10

‘mvn’ is not recognized as an internal or external command,

Do you have maven installed?

I am guessing not how to do this?

https://www.google.com/search?q=install%20maven