openhab / openhab1-addons

Add-ons for openHAB 1.x
Eclipse Public License 2.0
3.43k stars 1.69k forks source link

Add Binding for Velleman K8055 USB IO Board #330

Closed openhab-bot closed 10 years ago

openhab-bot commented 10 years ago

From AnthonyG...@googlemail.com on June 01, 2013 20:51:02

Velleman produce a USB Input-Output board: Velleman K8055: http://www.maplin.co.uk/usb-experiment-interface-board-42857 This has 8 digital inputs, 8 outputs and a few analog inputs/outputs

This is an easy and fairly cheap way to add some simple IO to openhab.

A binding for this in OpenHab would be useful.

Original issue: http://code.google.com/p/openhab/issues/detail?id=330

openhab-bot commented 10 years ago

From AnthonyG...@googlemail.com on June 01, 2013 12:01:53

I have made an initial go at a binding for this board. This is my openhab binding, so probably leaves a little to be desired. However it seems to work.

See: https://code.google.com/r/anthonygreen98-bindings/source/detail?r=b0416e90e58bd73f08adb5c5d1a62e130c308e16&name=k8055 == Item Syntax == k8055=":"

Where IO Type is one of: DIGITAL_IN DIGITAL_OUT ANALOG_IN ANALOG_OUT

And IO Number is the number (1-8) of the particular IO channel to bind to.

== openhab.cfg Config ==

refresh interval in milliseconds (optional, defaults to 60000ms, 50s)

k8055:refresh=300

Board Number. Defaults to 0

k8055:boardno=0

== TODO ==

The binding basically works, but is not well tested. Still known todos are:

Any review/comments welcome!

openhab-bot commented 10 years ago

From AnthonyG...@googlemail.com on June 01, 2013 12:07:31

Also should have mentioned - this binding uses JNA to access an existing native code library: http://libk8055.sourceforge.net/ You'll need to have that built and installed for the binding to work. I have tested in Linux, but as the Windows DLL Velleman supply has the same API as the Linux lib above it might work on windows too.

openhab-bot commented 10 years ago

From teichsta on September 06, 2013 07:54:38

due to lack of time on my side this binding won't make it into 1.3.

Anyhow, thanks for this contribution! We'll start reviewing it soon after the upcoming release.

Owner: ---

openhab-bot commented 10 years ago

From Jk2...@Web.de on September 24, 2013 14:14:13

Did some further testing on I/O Boad with following result: There are different I/O Boards on the market K8055/PVM110 and later ones K8055N-1/-2 PVM110N-1; On the latest ones the native code library LibK8055 needs to be adjusted. see also http://www.forum-raspberrypi.de/Thread-k8055n-2 My board - PVM11ßN-1 works only with the adjustment. Tried everything and linux and works perfect. So have compiled jar for K8055. According to logfile binding starts 20:27:39.089 DEBUG o.o.b.k.i.k8055Activator[:54]- k8055 binding has been started.

Definitions in item files are accepted as followed: /* K8055 */ String input1 "IN1 [%s]" {k8055="DIGITAL_IN:1"} Switch output3 "OUT3" {k8055="DIGITAL_OUT:3"}

Can also see log if I try the switch: 21:09:57.576 INFO runtime.busevents[:42] - out3 received command ON 21:09:58.322 INFO runtime.busevents[:42] - out3 received command OFF

However nothing happens on the I/O board and it appears that it is not connected

Guess there is still a problem that K8055 hadware is not found

Tried also adding following argument to the openHAB start script: -Dgnu.io.rxtx.SerialPorts=/dev/bus/usb/

But some -> no result

openhab-bot commented 10 years ago

From AnthonyG...@googlemail.com on October 07, 2013 09:21:08

It can take some fiddling for this to work properly. First check that "k8055" program that comes with the libk8055 library is working on your machine:

If not, it could be either a permissions problem; or the linux kernel loading the HID driver and conflicting with libk8055. I resolved both on my Ubuntu machine with a udev rule:

Create file: /etc/udev/rules.d/k8055.rules with the following contents:

K8055

SUBSYSTEM=="usb", ATTRS{idVendor}=="10cf", ATTRS{idProduct}=="5500", GROUP="plugdev", MODE="0660", OPTIONS="ignore_device"

Unfortunately the debug output from libk8055 is fairly minimal; so it isn't easy to work out why things aren't working from the openhab logs.

openhab-bot commented 10 years ago

From Jk2...@Web.de on October 12, 2013 05:18:26

Hi Anthony, Standalone k8055 program works fine after change in libk8055 as explained in #7 - see link. However all trial to access it from openhab failed so far as explained in #7

K8055 start but I do not see a messages that connection is successful. Perhaps I have an older source from what you are using; would be great to see an update/refresh in snapshot binding soon.

Thanks a lot for your work done so far k8055 board and openhab would be a great fit if the work finally.

Regards Jens

openhab-bot commented 10 years ago

From teichsta on November 05, 2013 14:47:54

Labels: To-Github

engineergreen commented 10 years ago

Updated to work with 1.4.0-SNAPSOT of openhab. If you are still having issues with the latest code; please turn on debug logging for this binding and report the debug messages that you see.

engineergreen commented 10 years ago

I have now also created a wiki page for the binding: https://github.com/openhab/openhab/wiki/Velleman-K8055-Binding

To avoid confusion as the code has not yet been merged into the main repo; I've not added a link to this page from the main wiki Table Of Contents.

raymonvdm commented 10 years ago

I am trying to use this binding using OpenHAB 1.5.0 and Windows 7 but the binding is not working yet and i am not sure how to troubleshoot

Note: The machine is running Windows 7 and HomeSeer2PRO where i`m using the K8055 board without issues. So it really seems to be related to OpenHAB/Java and all drivers are there. Altough there is a possibility in which i need to copy a dll to a specific directory ?

engineergreen commented 10 years ago

The first troubleshooting step is to turn up the log level for the binding. You can do this by editing the logback.xml (or logback_debug.xml if running in debug mode), adding the following line:

 <logger name="org.openhab.binding.k8055" level="TRACE" />

This is pretty verbose, so you'll want to turn it off once you've got it to work.

Having said that, the most likely problem is with JNA loading the native code library. Now, I should say that I've not actually tested this with the Windows DLL yet, only in Linux - but the windows DLL has the same API so it should work.

Putting the DLL somewhere in the windows PATH ought to work. Failing that edit the openhab startup batch file and add -Djna.library.path="D:\dlls\libk8055.dll" with the appropriate path to the k8055 DLL.

I believe the Velleman supplied DLLs are 32bit, so you'll need to be using a 32bit version of Java for this to work.

raymonvdm commented 10 years ago

I tried to modify the logback.xml but there are not additional log rules.


 <logger name="org.openhab.binding.cm11a" level="TRACE" />
 <logger name="org.openhab.binding.k8055" level="TRACE" />

I also added the following rule to start.bat

-Djna.library.path="C:\Program Files\Velleman\K8055\K8055D.dll"
engineergreen commented 10 years ago

Apologies, I copied and pasted the wrong bit of my logback.xml file - as you guessed, the correct log entry you need it:

 <logger name="org.openhab.binding.k8055" level="TRACE" />

If the line isn't there already, you can just add it. You'll then need to restart openhab and look for any lines in the log file with "k8055" in it.

Note that I've not yet tried this in Windows - once I've borrowed a Windows laptop I'll give it a go. Some thoughts though - the easiest way to get the DLL file in a place where it will be found will be to drop it into the windows\system32 folder. As the Velleman DLL is a 32bit library, you'll also need to use a 32bit version of Java.

teichsta commented 10 years ago

implemented and merged with PR #705 - if there are any errors regarding this binding please feel to open another issue