Update ZWave binding with new/updated device xml

Tl;dr - Your current Zwave binding can be updated with a new/modified Zwave device XML prior to a build being available using the “jar” command.

This updates the forum posting here (OH2 based) to OH3/OH4. Please review that posting first for background and cautions that still apply. Besides the “waiting for a build” this process could also be used to update an OH3 ZWave binding with a new/modified device that is only available in an OH4 binding due to limited OH3 “patch releases”.

As with most things “Linux”, there are multiple ways to accomplish the same task. As I am not a Linux expert, the commands I used may not be the best or most efficient.

  1. The first task is to get the modified XML to your local machine. After making your changes in the ZW device DB and tapping “Request Review” on the Overview tab, use the gear icon to “EXPORT OH2 XML”. Copy the contents to a local xml file. Naming the device xml can be tricky if there is a minimum version. Using this line as an example (thing-type id=“zooz_zse40_17_009” listed=“false”), name the xml “zse40_17_9.xml”. The 17_9 represents the minimum firmware version. For devices that have no minimum version the pattern is zse44_0_0.xml. Also note the [vendor] folder is the first section in the above line. As a PC user with Samba, I move the xml to the openhab-sys folder.
    Get XMLfrom DB
    Database export
  • Alternatively if you are updating an OH3 jar with a device already present in the OH4 binding use the “find file” from the Zwave github “code” tab to find the vendor folder and xml file name.
    Zwavebinding lookup
    download raw xml
  1. SSH into RPi using PuTTY or equivalent. Backup openhab just in case something goes astray.
BACKUP
openhabian@openhab:~ $ sudo openhab-cli backup
<SNIP> PROGRESS REPORTS
Success! Backup made in /var/lib/openhab/backups/openhab-backup-23_06_07-10_58_37.zip
  1. Create the following directory structure in a convenient location, jarmodify/OH-INF/thing/[vendor].
MAKE FOLDER STRUCTURE
openhabian@openhab:~ $ mkdir /home/openhabian/jarmodify
openhabian@openhab:~ $ mkdir /home/openhabian/jarmodify/OH-INF
openhabian@openhab:~ $ mkdir /home/openhabian/jarmodify/OH-INF/thing
openhabian@openhab:~ $ mkdir /home/openhabian/jarmodify/OH-INF/thing/zooz
  1. For OH3 installations, in particular, since the OH4 Zwave bindings are not compatible, find the UI installed Zwave binding on your RPi. If there is a previously modified binding it will be in the “Addons” folder (/usr/lib/openhab/addons).
FIND UI INSTALLED BINDING
openhabian@openhab:~ $ cd /  <--SWITCH TO ROOT
openhabian@openhab:/ $ sudo find -name "org.openhab.binding.zwave-*"
<SNIP> - COULD BE OTHERS, BUT THE ONES BELOW ARE THE LOCATION NEEDED (AND THE SAME)
./srv/openhab-userdata/tmp/kar/openhab-addons-4.0.0.M3/org/openhab/addons/bundles/org.openhab.binding.zwave/4.0.0.M3/org.openhab.binding.zwave-4.0.0.M3.jar
./var/lib/openhab/tmp/kar/openhab-addons-4.0.0.M3/org/openhab/addons/bundles/org.openhab.binding.zwave/4.0.0.M3/org.openhab.binding.zwave-4.0.0.M3.jar
  1. Copy current jar to the jarmodify folder created earlier.
COPY UI ZWAVE JAR TO JARMODIFY DIRECTORY
openhabian@openhab:~ $ cp /var/lib/openhab/tmp/kar/openhab-addons-4.0.0.M3/org/openhab/addons/bundles/org.openhab.binding.zwave/4.0.0.M3/org.openhab.binding.zwave-4.0.0.M3.jar /home/openhabian/jarmodify
openhabian@openhab:~ $ cd /home/openhabian/jarmodify (CHECK)
openhabian@openhab:~/jarmodify $ dir
OH-INF  org.openhab.binding.zwave-4.0.0.M3.jar
  1. Copy the device xml from step 1 into the /home/openhabian/jarmodify/OH-INF/thing/[vendor] folder. (openhab-sys = /usr/lib/openhab)
COPY XML FROM SAMBA (alias OPENHAB-SYS)
openhabian@openhab:~/jarmodify $ cp /usr/share/openhab/zse44_0_0.xml /home/openhabian/jarmodify/OH-INF/thing/zooz
  1. Update the jar while in the jarmodify folder.
UPDATE THE JAR WITH THE XML
openhabian@openhab:~/jarmodify $ jar uf org.openhab.binding.zwave-4.0.0.M3.jar ./OH-INF/thing/zooz/zse44_0_0.xml
  1. Open the karaf console, find current zwave bundle number and update the binding.
LOG INTO CONSOLE & FIND ZWAVE ID
openhabian@openhab:~/jarmodify $ sudo openhab-cli console
openhab> bundle:list |grep ZWave
254 x Active x  80 x 4.0.0.202305270039     x openHAB Add-ons :: Bundles :: ZWave Binding

UPDATE BINDING
openhab> bundle:update 254 file:///home/openhabian/jarmodify/org.openhab.binding.zwave-4.0.0.M3.jar
6 Likes

It had been a while since I had used this method and going through the example I had a problem with “jar command not found”. Since Java 8 (used in OH2), not all versions of Java include the “jar” class that is used to update the xml. This section should help, but there are lots of variations and they can’t all be covered. This a little more advanced using the update-alternatives command

  1. First find the configured version(s) of java. If there is more than one, openHAB is using the “auto” or highest priority. Also navigate to /usr/lib/jvm directory and check for installed, but not configured java versions and check the /bin file of each one for a “jar” file.
 CHECK INSTALLED JAVA VERSION(S) & LOCATION
openhabian@openhab:~ $ sudo update-alternatives --list java
/usr/lib/jvm/java-17-openjdk-armhf/bin/java
CHECK FOR JAR CLASS (TWO WAYS)
openhabian@openhab:~$ update-alternatives --list jar
update-alternatives: error: no alternatives for jar
OR (CHECK OTHER JAVA VERSIONS IN THIS DIRECTORY - IF ANY)
openhabian@openhab:~ $ cd /usr/lib/jvm
openhabian@openhab:/usr/lib/jvm $ dir
default-java  java-1.11.0-openjdk-armhf  java-1.17.0-openjdk-armhf  java-11-openjdk-armhf  java-17-openjdk-armhf  zulu17.38.21-ca-jdk17.0.5-linux_aarch32hf
openhabian@openhab:~ $ cd /usr/lib/jvm/java-17-openjdk-armhf/bin
openhabian@openhab:/usr/lib/jvm/java-17-openjdk-armhf/bin $ dir
java  jpackage  keytool  rmiregistry
openhabian@openhab:/usr/lib/jvm $ cd /usr/lib/jvm/zulu17.38.21-ca-jdk17.0.5-linux_aarch32hf/bin
openhabian@openhab:/usr/lib/jvm/zulu17.38.21-ca-jdk17.0.5-linux_aarch32hf/bin $ dir
jar        java   javadoc  jcmd      jdb        jdeps  jhsdb   jinfo  jmap  jpackage  jrunscript  jstack  jstatd   rmiregistry
jarsigner  javac  javap    jconsole  jdeprscan  jfr    jimage  jlink  jmod  jps       jshell      jstat   keytool  serialver

a) If the only java version is either java-17-openjdk-armhf or java-11-openjdk-armhf, on the command line; sudo apt-get install openjdk-17-jdk-headless (or -11- on some older OH3 installations).

INSTALL JAVA JDK WITH JAR CLASS (IF NEEDED)
openhabian@openhab:~ $ sudo apt-get install openjdk-17-jdk-headless
<SNIP> PROGRESS REPORTS
The following NEW packages will be installed:
  openjdk-17-jdk-headless
<SNIP> PROGRESS REPORTS
Setting up openjdk-17-jdk-headless:armhf (17.0.6+10-1~deb11u1+rpt1) ...
KEY UPDATE
update-alternatives: using /usr/lib/jvm/java-17-openjdk-armhf/bin/jar to provide /usr/bin/jar (jar) in auto mode
<SNIP> OTHER UPDATES
openhabian@openhab:~ $  cd /usr/lib/jvm/java-17-openjdk-armhf/bin (CHECK)
openhabian@openhab:/usr/lib/jvm/java-17-openjdk-armhf/bin $ dir
jar        java   javadoc  jcmd  jdeprscan  jfr    jimage  jlink  jmod      jps         jshell  jstat   keytool      serialver
jarsigner  javac  javap    jdb   jdeps      jhsdb  jinfo   jmap   jpackage  jrunscript  jstack  jstatd  rmiregistry

b) If there is another java version installed, but not configured and it contains the jar class add it as shown below. (I had previously used Zulu Java and it did contain the jar file-see above). Note I had already upgraded to the 17-jdk package so have two versions at this point.

ADD JAR FROM ANOTHER JAVA
openhabian@openhab:/ $ sudo update-alternatives --install /usr/bin/jar jar /usr/lib/jvm/zulu17.38.21-ca-jdk17.0.5-linux_aarch32hf/bin/jar 1111
openhabian@openhab:/ $ sudo update-alternatives --config jar
There are 2 choices for the alternative jar (providing /usr/bin/jar).

  Selection    Path                                                            Priority   Status
------------------------------------------------------------
* 0            /usr/lib/jvm/java-17-openjdk-armhf/bin/jar                       1711      auto mode
  1            /usr/lib/jvm/java-17-openjdk-armhf/bin/jar                       1711      manual mode
  2            /usr/lib/jvm/zulu17.38.21-ca-jdk17.0.5-linux_aarch32hf/bin/jar   1111      manual mode

Press <enter> to keep the current choice[*], or type selection number:

(note: I left the zulu java as lower priority to not interfere with Openhab.)

Hopefully either the jdk upgrade or configuring an existing java installation will allow the jar upgrade to proceed for your ZWave device xml.

4 Likes

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.