[solved] How to add binding source to working project in eclipse

I want to add the source of an existing binding to a working project in eclipse so I can debug the binding.

I followed these instructions to setup the IDE.
I now want to add another binding (zwave) to the project, but I don’t know how to do that.
I did the following steps:

step1
Added a pre-existing jar file into the working project successfully, using these steps so I can access the habmin via openhab.

step2
Built the zwave binding as follows:
Select OH1-Add-ons -> org.openhab.binding.zwave1
Project -> Clean / Build
The build completes successfully

step3
Tried adding the zwave binding as follows:
Right-click openHAB_runtime.launch -> Debug As -> Debug Configurations
select tab "Plug-ins"
select org.openhab.bindings.zwave (see here)

When I execute openhab (via Right-click openHAB_runtime.launch -> Debug As -> openHAB_Runtime)
I can access http://localhost:8080/habmin/index.html#/bindings and see the binding that were added to the project but the zwave binding is not in the list of available bindings (see here)

I also tried to add the zwave binding via
Project -> Properties -> Project References
(see here).
Still, zwave binding does not show up in the list of available binding within habmin

How should I add the binding into the working project, such that it appears in the list of bindings?

Follow the following steps - don’t import the JAR unless you just want to be able to run the binding - you won’t be able to change anything even if you add source.

  1. Fork the repository on Github (eg ZWave)
  2. Clone your repository to your local computer as described in the Github tutorial
  3. Open the openHAB Eclipse IDE
  4. Select the File | Import menu option
  5. Select General | Existing Projects into Workspace and click Next
  6. Select the root directory where you made the local clone of the repository
  7. Select the project and click Next
  8. The project will now be imported and available in the Package Explorer

I see the project in the Package Explorer (see img1). It is in 2 places (Other Projects, OH1 Add-ons) but not in Infrastructure.
When I run openHAB_Runtime.launch I don’t see the zwave in the list of available bindings in habmin (see img4)
When I right-click → Infrastructure → Properties, there is no zwave binding to add to the “Working set content” (see img2)

According to here, the only thing needed is to “add the source project to the workspace” which I thought I did (by copying the directory org.openhab.binding.zwave into the workspace, see img3), but apparently I’m not doing it right.

img1

img2

img3

img4

Sorry - I can’t see your images - can you put them in the post please?

I placed them in the post

You probably need to add ZWave to the debug set. Right click on the debug button and select configure. Then you need to add the ZWave binding to the list of running bundles.

In which tab? (see img1)
I was able to add the habmin jar in the “Plug-ins” tab, but now I want to add the zwave binding as source project
I tried adding in the zwave source project via the Plug-in (see img2), but it didn’t make any impact.

img1

img2

Plug-ins tab.

I tried adding in the zwave source project via the Plug-in (see img2), but it didn’t make any impact (see img2).
I think this is because the zwave binding is in a different section (“Worspace”) than bindings that do appear in habmin, e.g. yahooweahther in section “Target Platform” (see img3)

img2
https://community-openhab-org.s3-eu-central-1.amazonaws.com/original/2X/3/346291ef5bbba82dc7e9e23585dff67f535f78f3.png

img3
http://community-openhab-org.s3-eu-central-1.amazonaws.com/original/2X/0/0f5fc33697a109bff2f3f1c113dc590b2300bbd8.png

I doubt it - if it’s part of the workspace (ie it’s in the list of projects somewhere) then it should appear. If you’ve imported it into a completely separate workspace, then sure it won’t work. The section though doesn’t matter (the working sets I think it’s called?)

Ok, I reinstalled eclipse using only the “openHAB Development”, without all the oh1, oh2 (to make it lightwight).
I then added habmin as a jar. (I still needed to activate the habmin selection, after adding it, by selecting and right-clicking the openhab.target -> Debug -> Debug Configurations -> (tab) Plug-ins
and ticking the habmin (under “Target Platform”)

I then added the zwave binding (similar to doing steps 1-7 mentioned above), using the following steps:

  • step1 - add zwave binding
    step1.a - link zwave binding to the target platform
    Windows -> Prefernce -> Target Platform -> selected “openHAB Target Platform” -> Edit -> (in tab “Locations”) Add -> Directory
    pointed to zwave binding directory from previous eclipse installation (/home/avnerm/openhab2-master/git/openhab/bundles/binding/)
    In tab “Content”, enabled (ticked the box) org.openhab.binding.zwave
    step1.b - add the zwave binding to eclipse
    "Package Explorer" -> right-click on “Other Projects” -> Import -> Projects from Folder or Archive

  • step2 - build zwave binding
    Arbitrarily edited a file (ZWaveBindingProvider.java) within zwave source project.
    Added an erronous code line just to see that the project fails to build then removed the error, and verified that the project builds ok (errors are gone from e “Problems” pane)

  • step3
    Directed the eclipse console output into file

  • step4
    Invoked the openhab program
    Right-click openHAB_runtime.launch -> Debug As -> openHAB_Runtime

In the console log file, I do see the following log messages indicating that the zwave binding is engaged, but I still do not see it in the list of available bindings in habmin???

/tmp/eclipseOutput.txt

2016-11-25 14:29:08.634 [DEBUG] [.core.common.ThreadPoolManager:145  ] - Created thread pool 'safeCall' with size 5
2016-11-25 14:29:08.637 [DEBUG] [.zwave.internal.ZWaveActivator:37   ] - Z-Wave binding started. Version 1.9.0.qualifier
2016-11-25 14:29:08.657 [DEBUG] [c.x.o.XmlDocumentBundleTracker:126  ] - Reading the XML document '/ESH-INF/thing/ColorTemperatureLight.xml' in module 'org.eclipse.smarthome.binding.hue'.....
Service, policy = dynamic, cardinality = 0..n, target = null, bind = addActionService, unbind = removeActionService]
2016-11-25 14:29:09.457 [DEBUG] [.z.internal.ZWaveActiveBinding:177  ] - ConverterHandler not initialised. Polling disabled.
2016-11-25 14:29:09.458 [INFO ] [.z.internal.ZWaveActiveBinding:330  ] - ZWave 'updated' with null config
2016-11-25 14:29:09.461 [DEBUG] [c.x.o.XmlDocumentBundleTracker:126  ] - Reading the XML document '/ESH-INF/binding/binding.xml' in module 'org.eclipse.smarthome.binding.ntp'...
...

You don’t say that you added the ZWAve JAR to the running config.

I thought that in case of adding the source project, the jar file does not have to be added (unlike the habmin which is added as closed jar file without code). Do you know where the zwave jar file is stored in the org.openhab.binding.zwave1 project?
The only zwave related jar file that I can find is

find  /home/avnerm/openhab2-master -name "*.jar" | grep zwave
/home/avnerm/openhab2-master/git/openhab/bundles/binding/org.openhab.binding.zwave/lib/xstream-1.4.6.jar```
Is this the one?

You always have to update the debug plugins - always.

I thought you’d installed the source - so you should be running from the source - right?

The source is installed in

ll /home/avnerm/openhab2-master/git/openhab/bundles/binding/org.openhab.binding.zwave/
total 56
drwxrwxr-x   8 avnerm avnerm  4096 Nov 21 14:31 ./
drwxrwxr-x 168 avnerm avnerm 12288 Nov 25 14:07 ../
-rw-rw-r--   1 avnerm avnerm   223 Nov 21 14:23 build.properties
-rw-rw-r--   1 avnerm avnerm   499 Nov 21 14:23 .classpath
drwxrwxr-x  62 avnerm avnerm  4096 Nov 21 14:23 database/
drwxrwxr-x   2 avnerm avnerm  4096 Nov 21 14:23 lib/
drwxrwxr-x   2 avnerm avnerm  4096 Nov 21 14:23 META-INF/
drwxrwxr-x   2 avnerm avnerm  4096 Nov 21 14:23 OSGI-INF/
-rw-rw-r--   1 avnerm avnerm  1001 Nov 21 14:23 pom.xml
-rw-rw-r--   1 avnerm avnerm   840 Nov 21 14:23 .project
drwxrwxr-x   3 avnerm avnerm  4096 Nov 21 14:23 src/
drwxrwxr-x   3 avnerm avnerm  4096 Nov 21 14:31 target/

The only zwave related jar file that I can find is

find /home/avnerm/openhab2-master -name "*.jar" | grep zwave
/home/avnerm/openhab2-master/git/openhab/bundles/binding/org.openhab.binding.zwave/lib/xstream-1.4.6.jar

Is this the one (I expected it to have a name like org.openhab.binding…zwave…jar) ?

But you’re running the source project, so there’s no point in looking for a JAR. The JAR is created when you run the project.

I’m running the openhab source project (by doing right-click openHAB_runtime.launch → Debug As → openHAB_Runtime ) that should be linked to the zwave source project.

Isn’t step1 doing that? (see img1) and isn’t the log messages indicating that zwave is engaged?

img1

Yes, from the image, it looks ok - I’m not sure I understand what you wrote, but the image looks ok.

Should work fine I think.

I wanted to see if the debugger gets to execute the zwave code by setting a breakpoint in a central point, so I placed a breakpoint in ZWaveActivator.java, and the program gets there. I changed the log message:

from 
Z-Wave binding started. Version 1.9.0.qualifier
to
Z-Wave binding started111. Version 1.9.0.qualifier

stopped the program, re-invoked the debug and the change shows up in the log file

cat /tmp/eclipseOutput.txt
...
2016-11-25 15:31:35.113 [DEBUG] [.zwave.internal.ZWaveActivator:37   ] - Z-Wave binding started111. Version 1.9.0.qualifier

This indicates that the zwave binding is linked to the program.
Shouldn’t I see it in the list of bindings in habmin?

I’m working with org.openhab.ui.habmin_0.1.6.jar. According to the documentation this is Habmin2, right?

If this is Habmin2, then according to these comments, should I even expect that zwave binding will show up in habmin?

Also, the name of the binding in /home/avnerm/openhab2-master/git/openhab/bundles/binding/org.openhab.binding.zwave
is advertised as: org.openhab.binding.zwave1. Is there a reason for the “1” in the name “zwave1”?

I compared 2 use cases:
use case1
openhab2 + habmin + zwave binding within eclipse

  • does NOT show the zwave binding (img1)
  • not sure if the zwave version is 2.0.0.b3, or 1.9.0.b3 (snippet1)?

use case2
openhab2 from regular user install (using this tutorial)

  • does show the zwave binding (img2)
    zwave version 2.0.0.b3? (snippet 2)

snippet1

find  /opt/openhab2/ -name "*zwave*"
/opt/openhab2/runtime/karaf/system/org/openhab/addons/openhab-addons-external/1.9.0.b3/openhab-addons-external-1.9.0.b3-mios-zwavestatusin.map
/opt/openhab2/runtime/karaf/system/org/openhab/binding/org.openhab.binding.zwave
/opt/openhab2/runtime/karaf/system/org/openhab/binding/org.openhab.binding.zwave/2.0.0.b3/org.openhab.binding.zwave-2.0.0.b3.jar

snippet2

cat ~/openhab2-master2/git/openhab/bundles/binding/org.openhab.binding.zwave/pom.xml
...
		<version>1.9.0-SNAPSHOT</version>
...

img1


img2

Thanks