Altering JAR file for manual binding installation

I currently am having an issue getting UPB to work with OpenHab version 2.4 on a raspberry pi 3 b+. When I install the UPB binding (version 1.13) from Paper UI I can not control my UPB devices, Simply Automated Appliance modules and Leviton Light Switches, with simple ON or OFF commands. When I copy a UPB jar file named org.openhab.binding.upb-1.9.0-SNAPSHOT.jar (downloaded from https://github.com/openhab/openhab1-addons/pull/3883) into /usr/share/openhab2/addons I can control my UPB devices for several hours and then it no longer works and takes a log time to stop the openhab2 service waiting on the UPB binding. I have extracted and decompiled the contents of the JAR and based on my OpenHab log files it appears to be an issue when an ACK packet is not received from a UPB device. I have made small alterations to the code and recompiled it using the same Java version of 1.80_66 and receive no warnings/errors after being compiled. I also create the same folder structure as the original JAR and copy the other files such as MANIFEST.MF, pom.properties, pom.xml, binding.xml and genericbindingprovider.xml into the folder structure for my new JAR. I then create a JAR file and copy it to /usr/share/openhab2/addons and set the group and owner to openhab using chown openhab:openhab /usr/share/openhab2/addons/. Using the openhab-cli console I can see that the binding never gets installed by using bundle:list command. I also do not see any errors in /var/log/openhab2/openhab.log file. Does anyone have any ideas for me?

1 Like

Why not setup an IDE, add your changes to the Binding source and create a pull request (PR), so everyone could benefit from it ??

1 Like

That is my long term plan but didn’t want to use time figuring that out upfront when I need the UPB automation working. I read the documentation at https://www.openhab.org/docs/developer/ but it didn’t go into enough detail for me to figure it out. I also looked for a youtube video on getting started with development for OpenHab and didn’t find one. Once I figure out how this all works I will spend time on that so that hopefully in the future I can contribute to keep it working in future versions

With the updated docs it should be not too difficult to get Eclipse IDE running. All in all this might be easier than patching the jar file.

If you want a minimal setup you can simple clone the openhab1–addons GitHub repo and run maven on the command line for that specific binding to build the jar.

The eclipse ide documentation is being updated, a pull request is pending. Edit: link to updated documentation: https://www.openhab.org/docs/developer/ide/eclipse.html
The new documentation explains in a number of steps how to install Eclipse.

1 Like

I never really had much success with Eclipse (granted, this was a few months ago, using the old system and old instructions), but found it much simpler to get up and running with VScode recently.

Thank you for discovering the different behavior between the paper UI binding and the jar! Wouldn’t have tried the jar if I hadn’t found this thread. :100:

I’m experiencing the same behavior, in that the binding installed through the paper ui flatly doesn’t work, while the jar does. I haven’t experimented with it long enough yet to see if I lose control after a few hours.

I installed the latest version of the UPB binding through the paper UI, and confirmed I had the serial port working properly.
Debug logging showed that although a smarthome.ItemCommandEvent was firing, the UPB binding wasn’t actually being invoked in any way.
I dropped in the 1.9.0 jar instead, and immediately was able to actually get UPBWriter events firing as they should and traffic on my serial port.

@djg8544 I couldn’t find you on github - do you have an active fork going somewhere? I’d collaborate with you if so.

OpenHab 2.5.0~M4-1
UPB Binding from paper ui: binding-upb1 - 1.14.0.M4

I found a later version (2.0 Snapshot) of the upb binding, https://github.com/openhab/openhab2-addons/pull/1620, which is working good for me. If you are still using the 1.9 version I would start using this one as it works well and is written for openHAB 2.0 utilizing things. You will just need to alter your upb config files but the link explains that.

@djg8544 Thanks. On your suggestion, I tried 2.0, but the long series of refreshes after every single command – which block new commands from going through – made it totally unusable for me.

As far as I can tell it’s the thing complained about here and explained two posts below that. Even with only the PIM and 3 lamp modules it’s already a 4 second delay between successive commands, and I believe it’ll increase by a second with each and every UPB device I add.

Hopefully you find some workaround to that problem if you’re going to use 2.0 in any substantial way.

For what it’s worth, I couldn’t duplicate your difficulties with 1.9; even after multiple days the system still responded immediately to new commands.