Plcbus addon not working in OH2

Hi all,

I’m trying to get a plcbus addon running under OH2 without luck.
I installed the openhab-offline-2.0.0-SNAPSHOT.

My openhab.log says:
2016-11-22 02:01:42.033 [ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing ‘openhab-binding-plcbus’: No matching features for openhab-binding-plcbus/0.0.0

In C:\openhab\addons I have org.openhab.binding.plcbus-1.8.3.jar

In my addons.cfg I have:
remote = true
legacy = true
binding = plcbus

Karaf feature:list says:
openhab-transport-serial | 2.0.0.b4 | x | Started | openhab-aggregate-xml | Serial Transport
openhab-runtime-compat1x | 2.0.0.b4 | x | Started | openhab-aggregate-xml | Compatibility layer for openHAB 1 addons

What am I doing wrong?

If this is not a binding that is part of the distribution:

http://docs.openhab.org/developers/development/compatibilitylayer.html#how-to-use-openhab-1x-add-ons-that-are-not-part-of-the-distribution

Yes, it is not part of the distribution. Thats why I already followed the instructions on that page you linked. Did I miss something? What does the error message mean? I have no idea what to try next.

Given the what your first post said you did it seems you did not follow the instructions at that link. For add ons that are not part of the distribution you must:

  1. install the compatibility layer
  2. add the jar file to addons
  3. make a copy of openhab.cfg and place it in conf/services; comment out all the sections except for the one relevant to this binding
  4. take any other configuration steps the binding may require as defined on the wiki or whereever the binding came from
  5. restart openHAB 2.

addons.cfg is not involved at all and that is the source of the error You have put a binding (plcbus) that is not part of the distribution into addons.cfg so it couldn’t find it.

Thanks for the details. I did follow all the instructions. As you can mostly see in my first post. At least in my understanding. please correct me if I’m wrong.
I didn’t mention that I also added the openhab.cfg file to conf/services which contains the line “plcbus:port=COM1” and all other lines commented out (According to your step 3.)
Obviously it was wrong to put “binding = plcbus” in my addons.cfg. I deleted that entry now but nothing changed after a restart. Is it enough to remove that entry or is that setting stored somewhere else now?
I still get the error:
[ERROR] [core.karaf.internal.FeatureInstaller] - Failed installing ‘openhab-binding-plcbus’: No matching features for openhab-binding-plcbus/0.0.0
Is there anything I can check to get closer to the problem?

I don’t know. You can delete userdata/cache and userdata/tmp after removing it from add-ons.cfg and see if that changes. But this error really isn’t causing any problems. It can’t find the binding and so it moves on.

OK, I deleted cache and tmp. The previous error is gone. But the PLCBus binding doesn’t work. The serial port is not even opened after I start openHAB. Is there any way to get debug information? I can’t find anything related to the PLCBus binding in the logfiles. I don’t even know if it is running or not.

did you reinstall the compatibility layer after deleteing cache? When you delete cache that got blown away along with the other installed add-ons.

Yes, feature:list returns:

openhab-runtime-compat1x | 2.0.0.b4 | x | Started | openhab-aggregate-xml | Compatibility layer for openHAB 1 addons

I also did feature:install openhab-transport-serial
because without it I had the error:

2016-12-01 00:44:39.524 [WARN ] [org.apache.felix.fileinstall ] - Error while starting bundle: file:/C:/openhab/addons/org.openhab.binding.plcbus-1.9.0.b3.jar
org.osgi.framework.BundleException: Could not resolve module: org.openhab.binding.plcbus [178]
Unresolved requirement: Import-Package: gnu.io

now no errors appear in the log but the port stays closed and available and nothing is being sent if I try to use the binding.
I have this Line in my demo.items:
Dimmer Light_GF_Test “PLC” (gGF, GF_Living, Lights) { plcbus=“D1 A2 5” }

I’m really out of ideas. I’m still trying to learn the ins and outs of OH 2 myself so can’t offer any more advice.

OK thanks Rich.
Is noone using PLCBUS out there?:cry:

A mate of mine tried to get the PLCbus binding working on 1.8… he spent days hacking around the binding code without any real success.

I suggested he try using the exec binding to call an external script which he already had…i dont recall how that went, but he’s in the process of removing his plcbus hardware.

1 Like

I don’t use it, but I had a quick look at the code and it seems that no one adapted the binding yet to correctly start on OH2.
I just quickly compiled a patched version and uploaded it here: https://dl.dropboxusercontent.com/u/15535378/org.openhab.binding.plcbus_1.9.0.201612010905.jar

Please test if this makes a difference (and make sure to bundle:uninstall the previous version that you have already installed).

1 Like

Awesome, thank you Kai!
Now the COM Port is being opened when I start OH2 and closed when I logout OH2.
However nothing comes out.
I bundle:uninstalled the previous version. Only yours is being listed now.
In my demo.items I have:
Dimmer Light_GF_Test “PLC” (gGF, GF_Living, Lights) { plcbus=“D1 A2 5” }
When I move the slider in my Basic UI I get lines like this in events.log:
2016-12-03 20:55:25.301 [ItemCommandEvent ] - Item ‘Light_GF_Test’ received command 46
2016-12-03 20:55:25.303 [ItemStateChangedEvent ] - Light_GF_Test changed from 0 to 46
Did I miss a step during installation/configuration? Should I delete cache or temp?

Doesn’t sound like it. Maybe the binding is a bit buggy regarding the expected start order.
You could try to play around by touching the item file during runtime, to make it being re-parsed and also by stopping and starting the binding bundle (find its id by list -s and then do a stop <id> and start <id>. Maybe this makes any difference.
Also check for debug log messages by enabling debug logging through log:set DEBUG org.openhab.binding.plcbus.

I tried stopping and starting it. I also stopped and started org.openhab.io.transport.serial.
I’ve done log:set DEBUG org.openhab.binding.plcbus.
In events.log I get:
2016-12-04 13:12:56.038 [DEBUG] [e.osgi.LoggingCommandSessionListener] - Executing command: 'start 182’
2016-12-04 13:12:56.052 [DEBUG] [mpl.info.InfoBundleTrackerCustomizer] - Ignore incorrect info null provided by bundle org.openhab.binding.plcbus
2016-12-04 13:12:56.052 [INFO ] [g.apache.aries.spifly.dynamic.bundle] - Bundle Considered for SPI providers: org.openhab.binding.plcbus
2016-12-04 13:12:56.052 [INFO ] [g.apache.aries.spifly.dynamic.bundle] - No ‘SPI-Provider’ Manifest header. Skipping bundle: org.openhab.binding.plcbus
2016-12-04 13:12:56.053 [DEBUG] [e.osgi.LoggingCommandSessionListener] - Command: ‘start 182’ returned ‘null’

Unfortunately nothing is being sent to the COM Port.
Also nothing interesting shows up in events.log when I move this slider:
Dimmer Light_GF_Test “PLC” (gGF, GF_Living, Lights) { plcbus=“209 D3 5” }

In events.log I still just get:
2016-12-04 21:26:06.599 [ItemStateChangedEvent ] - Light_GF_Test changed from 35 to 70
2016-12-04 21:26:06.797 [ItemCommandEvent ] - Item ‘Light_GF_Test’ received command 70

Could something be wrong with the syntax in my demo.items?
Can I somehow trigger the binding from Karaf istead of through the UI?

I tried to use a commandline exe (like greg suggested) for making shure that the PLCBus Interface works.
I used this one:
https://sourceforge.net/projects/plcbus-cmd/
With commands like this:
plcbus_cmd.exe -pCOM1 -T1 -s209 -hD -u3 -cPDIM050,001
It works perfectly fine. I can control a dimmer and I see the commands that it sends in my serial monitor tool.

But I dont know how I could make the exe work with a slider in the UI. Also I want to move OH2 to a Raspberry PI later and I won’t have the exe there.