Amending existing binding code - what is the "right" way to install it?

For future use:
My setup: a laptop for coding & compiling, rpi running openHUB.

  1. git clone GitHub - openhab/openhab-addons: Add-ons for openHAB
  2. find the binding to work on, in my case it’s in openhab-addons/bundles/org.openhab.binding.denonmarantz
  3. compile the binding without any code changes to make sure the compilation works OK
mvn clean install -pl :org.openhab.binding.denonmarantz
  1. On compiling errors first check java --version and mvn --version and make sure it’s all OK with the versions
  2. Make changes or apply patches
  3. Compile again
  4. Successful compilation producer jar file in the target directory. In my case in openhab-addons/bundles/org.openhab.binding.denonmarantz/target and the file is called org.openhab.binding.denonmarantz-4.1.0-SNAPSHOT.jar
  5. Transfer the file to the hardware running openhab to /usr/share/openhab/addons/ (on raspbian)
    9 Change the ownership of the file with
sudo chown openhab:openhab org.openhab.binding.denonmarantz-4.1.0-SNAPSHOT.jar
  1. log in openHAB console with ssh -p 8101 openhab@localhost
  2. search for the binding:
openhab> la -s|grep -i denonmarantz
237 │ Active   │  80 │ 4.0.1                  │ org.openhab.binding.denonmarantz
245 │ Active   │  80 │ 4.1.0.202308011911     │ org.openhab.binding.denonmarantz
  1. check the files (one is the original one, one is modified):
openhab> la -l|grep -i denonmarantz
237 │ Active   │  80 │ 4.0.1                  │ mvn:org.openhab.addons.bundles/org.openhab.binding.denonmarantz/4.0.1
245 │ Active   │  80 │ 4.1.0.202308011911     │ file:/usr/share/openhab/addons/org.openhab.binding.denonmarantz-4.1.0-SNAPSHOT.jar

13 Uninstall the original binding and check it’s removed:

openhab> uninstall 237
openhab> la -s|grep -i denonmarantz
245 │ Active   │  80 │ 4.1.0.202308011911     │ org.openhab.binding.denonmarantz
openhab> la -l|grep -i denonmarantz                                                                                                                                                           
245 │ Active   │  80 │ 4.1.0.202308011911     │ file:/usr/share/openhab/addons/org.openhab.binding.denonmarantz-4.1.0-SNAPSHOT.jar
  1. I run update (looks like OH3 might behave in a different way than OH4:
update 245 file:/usr/share/openhab/addons/org.openhab.binding.denonmarantz-4.1.0-SNAPSHOT.jar
  1. Enjoy!
1 Like