Newbie trying to develop & debug for OpenHab

I have installed with help of command prompt and used the User Interface to install bindings with JAR files and work with Homeconnect devices throught BSH servers. It works well and its amazing!!!

However since I am not using any IDE so I have limited control over things, items and rules. I want to start developing and use code like we do in Raspberry pi.

I intend to work with a Windows 10 Home 64 Bit. I am following this link


and

I have tried installing the IDE. Its somehow important to be downloaded to the OpenHab directory which was already installed at my PC. otherwise errors appear. Anyhow moving forward, Eclipse was installed however while running the demo app I got these error (see picture attached)

Can anyone please advise me how to proceed. I am confused like where to code if I dont want to use the user interface. where is the binding configurations as they show in video etc.

Also if there is good guide of using openhab with Eclipse please let me know. I know that in Python its easier but I want to do in JAVA… All i want is to write rules and establish things and control them with code and share with other people.

Regards,
Owais Ahmed

OpenHAB is written in Java. You can write automation rules in Jython which is compatible with Python 2. Is that what you mean? You do not need Eclipse for that.

Your first link was for openHAB 2.2. I am sure the development environment for 2.5 is different.

Dear Sir,

Thankyou so much for your quick response. I am very glad people like you are in this platform.
Since I want to get my skills brushed again in Java(used Netbeans in 2015) i plan to develop and debug through Eclipse. However I just cant visualize all the bindings in the addons folder nor the repository or anything. If that gets done, I am more than happy to grasp the style of coding very fast.

I am not sure if I am installing correctly because with command prompt user interface and all works well. but with Eclipse. I am totally blank. Thanks to highlight the version issue though. Do u recommend VS code for beginners?

Regards,
Owais Ahmed.

I have not begun to code for OH and have not really worked with Java. There are some development experts here that can help.

I am having trouble understanding what you with to accomplish. Are you hoping to develop a BSH Home Connect binding?

For homeconnect I am trying use the OSGI Bundle found at the link below. How to download it etc how to work with it ? followed his guide

Rather than what i did right now: just directly work with the JAR file and UI which I downloaded from here:
Home Connect addon: Looking for beta testers.

I pasted this in addon and included this binding. and it works but I have no code access etc.

I tried sending commands through Karaf console but where do I develop a script in which I can make my own program . Like instead of JAR files how do u deal with bindings to customize them in code rather than UI?

Regards,
Owais Ahmed.

If you mean Jython, I just did a quick search. Perhaps this thread can help/

1 Like

Your questions and goals are jumbled.

openHAB is written in Java. If you want to code add-ons for openHAB (e.g. a binding that connects to some device or technology that isn’t already supported) you need to use Java and you need to start here.

This does nothing for you for “things, items and rules.” These are not written in Java and do not use Java. Things and Items are written in a domain specific language (DSL). For Rules you have several options.But in both cases, the “IDE” for development of openHAB configurations is VSCode with the openHAB extension.

For Rules you have the choice between Rules DSL, Jython, JavaScript, or Groovy but not Java. If you are just getting started, I would not recommend Rules DSL as it’s future is not certain and it has a number of limitations. Jython has the most documentation and examples on the forum outside of Rules DSL. But pretty much all of us use VSCode to develop Rules.

So which is your main goal, to relearn Java or develop openHAB configs? The answer to that will lead you to the correct path.

This is not done and cannot be done in Java at this time. Well, this isn’t strictly true as I’m told that there is one person who knows how to do it but this sentence is the extent of the documentation for how to do it. So for all practical purposes it cannot be done.

If you are creating openHAB configurations in text files than I recommend VSCode with the openHAB extension for all users.

You really need to spend some time reviewing the Concepts section of the docs and perhaps some of the resources at How to get started (there is no step-by-step tutorial). You seem to have a real misunderstanding about how OH works. At a very high level:

  • Bindings connect to devices, APIs or technologies
  • Bindings represent individual devices as Things
  • Individual actuators or sensors on a device are represented as Channels
  • Channels are Linked to Items, Items are the model of your home automation, they are where you go from something meaningless like zwave:controller:node12:switch to something meaningfule like LivingroomLamp; pretty much everything in OH works with Items
  • Items receive updates or can receive commands to control the device (i.e. send command to Item which goes to the binding where it goes out to the device)
  • behaviors are defined using event driven Rules; e.g. when Item Foo receives command ON, send command ON to Item Bar

You don’t mess with JAR files. You don’t customize the binding’s Java code (unless you are trying to add a feature or fix a bug). You write Rules that work on Items. And to do that you use one of the four supported languages.

1 Like