I’m working on changes to denonmarantz binding but I’m struggling to find in documentation what’s the best way to develop code in an existing binding.
My setup: openHAB installed on raspbian on raspberry pi, so there is a kar file in the system with all add-ons, including the one I’m trying to improve. The system kar file is in /usr/share/openhab/addons/openhab-addons-3.4.2.kar. For code development I use vim+syntastic on a fedora linux (a separate machine)
What I did so far:
Cloned openhab-addons, modified and compiled the code, so I generated org.openhab.binding.denonmarantz-3.4.2.jar file.
Copied the file to /usr/share/openhab/addons/ on the raspbian/openhab machine.
The commands doesn’t generate any output or errors, but nothing seems to be changing in the system.
I don’t see any new binding.
Now the question: how can I install the modified extension? Should I change the version for the modified binding? Change the name? Create a copy with a new name?
There is definitely something obvious that I’m missing. Any advice or hint how to proceed would be welcome!
P.S. I read about setting the IDE but it doesn’t say how to install the developed code. Maybe Eclipse does that part, but I prefer simple bulletproof tools.
Updating existing binding can go in selective way. If you have a build which does not change dependencies then:
openhab> la -s|grep -i astro
286 | Active | 80 x 3.0.2 | org.openhab.binding.astro
openhab> update 286 file:/some/file/in/my/filesystem/created-by-me.jar
openhab> la -l|grep -i astro
286 | Active | 80 x 3.0.2 | file:/some/file/in/my/filesystem/created-by-me.jar
Above way updates just sinlge line. Command in line 1 allows to find module id (286 in above example). The update call in third line tells to load another file for that module. Command in fourth line confirms that updated location is accepted. You can notice that there are two switches -s which prints module name and -l which prints its update location.
Update location is retained across restarts, so subsequent updates can be done with update 286. You need to specify update location only if you change it.
Thanks for help Łukasz! I have a first working version of the amended denonmatantz binding
Lessons learned:
la is the same as bundle:list
to point to a file one had to use file:// prefix
no need to rename jar to kar
diag can help with diagnosing problems with binding installation
if you get bundle status other than Active it probably makes sense to remove is (from GUI), install again (form GUI) and then update the modified version on top of it.
Once the setup is fixed the process of developing (code change, compile, deploy) takes a few seconds. I use scp to copy the file over the the openhab machine.
Each call of update command copies contents of referenced file into userdata/cache directory. As long as you do not do a “clean” start of openHAB you do not need to worry about reset. Also update of file does not affect contents of storage directory, unless you call update again.
In order to revert to previously known state you can do update xyz mvn:org.openhab.addons/abc/version. This will simply fetch a abc module from runtime/system directory.
Long story short - when you download openHAB you have copy of everything in runtime/system directory. When you launch it for first time its size almost doubles, cause major part of runtime contents gets copied to userdata/cache to retain actual runtime state.
On compiling errors first check java --version and mvn --version and make sure it’s all OK with the versions
Make changes or apply patches
Compile again
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
Transfer the file to the hardware running openhab to /usr/share/openhab/addons/ (on raspbian)
9 Change the ownership of the file with