How to deploy a custom binding to a production deployment?

Hi,

I have managed to successfully create a new binding and got it working in my eclipse development environment. However, I would like to deploy it for testing purposes on my “production” environment, a raspberry PI running raspbian. On this PI, I have installed openhab 4.1 through the package manager and it uses an extensive configuration already fore many years :slight_smile:

I managed to deploy the custom created jar file into the openhab 4.1 environment through the karaf console using bundle:install. The bundle installed correctly and shows it has status “Active”. However, I cannot create a thing associated with the binding, nor can I find the binding in the web interface. Using the route through the add-ons folder does yield a similar result.

What step am I missing?

Maybe you have an issue with the addon.xml.

It looks okay on inspection.

<?xml version="1.0" encoding="UTF-8"?>

<addon:addon id="broadlink" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance"
    xmlns:addon="https://openhab.org/schemas/addon/v1.0.0"
    xsi:schemaLocation="https://openhab.org/schemas/addon/v1.0.0 https://openhab.org/schemas/addon-1.0.0.xsd">
    <type>binding</type> 
	<name>Broadlink Binding</name>
	<description>This is the binding for Broadlink devices. It includes support for A1 multi-sensor, MP1/MP2 WiFi Smart Power Strip, SP1/2/3 WiFi smart socket, and RM2/3/4 IR transmitter</description>
	<connection>local</connection>	   
</addon:addon>

Is there any way I could diagnose whether this is the case?

P.S.
As you can tell I’m working on porting the earlier proposed broadlink binding to 4.1

It’s also important the addon.xml file is in /src/main/resources/OH-INF/addon or it won’t work.
If you post a link to the code on GitHub people can look/help.

I had this happen recently and for me it was I had cut and pasted some lines from another working binding and had not made the change to the binding ID. Check the thing-types.xml or where your things are defined and make sure they have the correct binding ID that matches all other configs/xml.

The logs sometimes complain when there is a typo and provide a clue.

I think some changes were made to the addon. Xml file as I updated a binding I created years ago and had to copy some contents across after doing a rebase. So compare against a merged binding as they get upgraded when changes are made, and if yours was sitting around it would not have gotten the update.

Here is the link to the right github location with the code:

This is not the case.

This seems to be the case.

Can you try moving addon.xml from directory binding to addon?

Done, it does not seem to help :frowning: It also still does not show up in the rest/addons API call.

I downloaded the .jar from the repository (https://github.com/AntonJansen/openhab-addons/blob/broadlink-binding-4.1.x/bundles/org.openhab.binding.broadlink/org.openhab.binding.broadlink-4.1.0-SNAPSHOT.jar) and dropped that into the addons folder of my 4.2.0-SNAPSHOT and it works fine:



1 Like

Try clearing your web browsers cache or doing a ctrl f5 if that forces a full refresh in your browser.

@J-N-K good to hear that the jar file itself works. Clearing the browser cache does not help. Somehow the binding does not register / install itself. I cannot find it through the rest/addons API call, nor create a thing with this binding, nor find it in the add-on store. The karaf console does say it is Active.

I will try to make a backup of the system and see if I can get it working through the addons.cfg file.

I would suggest to add a DEBUG logger for org.openhab.core.addon.internal.JarFileAddonService and remove/wait/readd the file. You should see the result of logger.debug("Added {} to add-on list", bundle.getSymbolicName());. If not, then the JarFileAddonService is not recognizing the bundle.

Thanks, this put me on the right track. The binding was not being added to the addons list. Reading up the code it seems it checks for the existence of OH-INF/addons/addons.xml

This was a fix I made, but I still used the bundle:install and bundle:remove to add and remove the binding.

It seems that adding the correct jar file in the add-ons folder does an additional step, which is missing from bundle:install: adding the binding to the addonInfoRegistry.

TLDR;
When making a binding, ensure you have a OH-INF/addons/adddons.xml file and put the jar of your binding in the addons folder and do not use bundle:install.

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