How to install MCP23017 binding with .jar file

i want to installing MCP23017 Binding and MCP 3424 Binding on Openhab2 but i don’t find them in: Paper IU addons
and then, I have followed these steps:

  • download: org.openhab.binding.mcp3424-1.9.0.jar and org.openhab.binding.mcp23017-1.9.0.jar and copy it into /usr/share/openhab2/addons folder
  • run: sudo chmod openhab.openhab /usr/share/openhab2/addons /org.openhab.binding.mcp23017-1.9.0.jar
    but It does not work and has information" chmod: invalid mode: ‘openhab.openhab’"
    ( I also tried configuring etc/openhab2/services/addons.cfg )
    then i try install with : sudo apt-get install openhab-addon-binding-mcp23017 but it still unsuccessful

so, how can i install mcp23017 binding and mcp3424 binding on openhab2
i know “This binding works nicely with openHAB 1.8.3 and 2.0.0 runtimes”
thanks for any help

Hi @thetrung,

try to execute

sudo chmod openhab:openhab /usr/share/openhab2/addons/org.openhab.binding.mcp23017-1.9.0.jar

and not

sudo chmod openhab.openhab /usr/share/openhab2/addons/org.openhab.binding.mcp23017-1.9.0.jar

Please take “:” instead of “.” into account. Login into karaf console via ssh and take a look, if binding was load.
Be sure, that openhab user is in gpio group.

Kind regards,

Alexander

1 Like

i follow your guide but it still has information" chmod: invalid mode: ‘openhab:openhab’" like of me
thanks you
PS/
I login to karaf and see this


is this mean that i install MCP23017 Binding?

Hi @thetrung,

sorry about late replay. We had cool weather :slight_smile:
Yes, bindings are installed and active.

And the properly call for owner change is

sudo chown openhab:openhab /usr/share/openhab2/addons/org.openhab.binding.mcp23017-1.9.0.jar

If you will change access rights, then use

sudo chmod ...

Sorry, mis-read your post first time.

Kind regards,

Alexander

thanks you, so much.
good luck for you,

hi alex,
to day, i checked mcp23017 binding, but it not work
i see in: Org.openhab.binding.i2c or org.openhab.binding.mcp23017
and install pi4j and check i2c with command: sudo i2cdetect -y 1
then i check openhab.log and it has error
Line 20106: 2017-06-06 19:54:30.285 [WARN ] [org.openhab.binding.mcp23017 ] - FrameworkEvent WARNING - org.openhab.binding.mcp23017
Line 20106: 2017-06-06 19:54:30.285 [WARN ] [org.openhab.binding.mcp23017 ] - FrameworkEvent WARNING - org.openhab.binding.mcp23017
Line 20256: 2017-06-06 20:09:54.395 [ERROR] [org.openhab.binding.mcp23017 ] - [org.openhab.binding.mcp23017.binding(10)] Error during instantiation of the implementation object
Line 20256: 2017-06-06 20:09:54.395 [ERROR] [org.openhab.binding.mcp23017 ] - [org.openhab.binding.mcp23017.binding(10)] Error during instantiation of the implementation object
Line 20259: at org.openhab.binding.mcp23017.internal.MCP23017Binding.(MCP23017Binding.java:83)
Line 20259: at org.openhab.binding.mcp23017.internal.MCP23017Binding.(MCP23017Binding.java:83)
Line 20259: at org.openhab.binding.mcp23017.internal.MCP23017Binding.(MCP23017Binding.java:83)
Line 20305: 2017-06-06 20:09:54.424 [WARN ] [org.openhab.binding.mcp23017 ] - FrameworkEvent WARNING - org.openhab.binding.mcp23017
Line 20305: 2017-06-06 20:09:54.424 [WARN ] [org.openhab.binding.mcp23017 ] - FrameworkEvent WARNING - org.openhab.binding.mcp23017
Line 20455: 2017-06-06 20:12:40.080 [ERROR] [org.openhab.binding.mcp23017 ] - [org.openhab.binding.mcp23017.binding(10)] Error during instantiation of the implementation object
Line 20455: 2017-06-06 20:12:40.080 [ERROR] [org.openhab.binding.mcp23017 ] - [org.openhab.binding.mcp23017.binding(10)] Error during instantiation of the implementation object
Line 20458: at org.openhab.binding.mcp23017.internal.MCP23017Binding.(MCP23017Binding.java:83)
Line 20458: at org.openhab.binding.mcp23017.internal.MCP23017Binding.(MCP23017Binding.java:83)
Line 20458: at org.openhab.binding.mcp23017.internal.MCP23017Binding.(MCP23017Binding.java:83)
Line 20504: 2017-06-06 20:12:40.110 [WARN ] [org.openhab.binding.mcp23017 ] - FrameworkEvent WARNING - org.openhab.binding.mcp23017
Line 20504: 2017-06-06 20:12:40.110 [WARN ] [org.openhab.binding.mcp23017 ] - FrameworkEvent WARNING - org.openhab.binding.mcp23017
Line 20685: 2017-06-06 20:24:35.998 [ERROR] [el.item.internal.GenericItemProvider] - Binding configuration of type ‘mcp23017’ of item ‘Test1’ could not be parsed correctly.
Line 20688: at org.openhab.binding.mcp23017.internal.MCP23017GenericBindingProvider.processBindingConfiguration(MCP23017GenericBindingProvider.java:80)
Line 20688: at org.openhab.binding.mcp23017.internal.MCP23017GenericBindingProvider.processBindingConfiguration(MCP23017GenericBindingProvider.java:80)
Line 20688: at org.openhab.binding.mcp23017.internal.MCP23017GenericBindingProvider.processBindingConfiguration(MCP23017GenericBindingProvider.java:80)
Line 20771: 2017-06-06 20:24:37.102 [INFO ] [b.core.service.AbstractActiveService] - mcp23017 Refresh Service has been started

so What is my problem?
i install openhab 2 on raspi 3
when i use KNX binding it have knx.cfg. so i can find .cfg file for mcp23017 binding?
thanks you so much for your answer :heart_eyes:

Hi @thetrung,

binding does not need any configuration. All the stuff is done via item definition. Have never seen this error before :frowning: Do you have only one version of binding active? Normally, you will not need pi4j, since it’s already in binding jar. But this time it will help: Can you check, if MCP23017GpioExample from pi4j examples run?

Kind regards,

Alexander

hi alex
i test MCP23017GpioExample from pi4j on my raspi 3 and it run ok
i still have no idea to solev it. but i have question:

  • I have 2 versions of mcp23017 binding
  • first is : org.openhab.binding.networkhealth-1.9.0.jar from openhab-1.9.0-addons.rar ( i coppy it on addons folder and run it with command: sudo jar xf org.openhab.binding.mcp3424-1.9.0.jar) ( i download it from: https://bintray.com/openhab/mvn/openhab1-addons/1.9.0)
    and this ít my addons folder on raspi3 install openhab2
    +orther: i have openhab1-addons-master.rar and i found org.openhab.binding.mcp23017 folder
    ( i download from: https://github.com/openhab/openhab1-addons)
    so i don’t know what is good version for my install
    can you help me?
    thanks you

Hi @thetrung,

github repository contains source code only. There is no binary to run. You need only *.jar files in addon folder. Leave readme.txt also, if it was installed with openHAB. You can delete another files/folders. mcp3424 binding supports MCP342X ADC - chips . For support of MCP23017 chips org.openhab.binding.mcp23017-1.9.0.jar is fine.

Kind regards,

Alexander

hi alex
I thankful your help and
Sorry if I bother you
in reinstall openhab2 and mcp23017 binding by copy file org.openhab.binding.mcp23017-1.9.0.jar to /usr/share/openhab2/addons/
but now it still this error when i check openhab.log is:
[ERROR] [org.openhab.binding.mcp23017 ] - [org.openhab.binding.mcp23017.binding(10)] The removeBindingProvider method has thrown an exception
23017 error.pdf (131.8 KB)
i with check cmp23017 with pi4j example and it work ok
and i check mcp23017 with command : sudo i2cdetect -y 1 and it’s ok
i don’t know my problem
thanks you for any help

Hi,

you can ignore removeBindingProvider errors. Something going wrong during openHAB shutdown.
More interessant is error about opening of I2C bus during addBindingProvider. As i’ve seen, you restart
openHAB again after this error again. This time without errors. It should work now. If not, only debugger can help now.

Kind Regards,

Alexander

hi alex-my brother
thanks you so much .
to day is my lucky day because 23017 binding is work ok



Thanks for all your help

all work with mcp23017 binding

S 1: install openhab
S 2: copy file org.openhab.binding.mcp23017-1.9.0.jar to /usr/share/openhab2/addons/
S 3: run command

  • sudo chown /usr/share/openhab2/addons/ org.openhab.binding.mcp23017-1.9.0.jar
  • test active org.openhab.binding.mcp23017-1.9.0.jar on karaf by
    run : ssh -p 8101 openhab@localhost
    yes
    pass: habopen
    run: list and find binding had active
    S 4: install pi4j
    wget http://get.pi4j.com/download/pi4j-1.1.deb
    sudo dpkg -i pi4j-1.1.deb
    This will install the Pi4J libraries and example source files to:
    /opt/pi4j/lib
    /opt/pi4j/examples
    compiler
    javac -classpath .:classes:/opt/pi4j/lib/’’ …
    run
    sudo java -classpath .:classes:/opt/pi4j/lib/’
    ’ …
    compiler all example
    /opt/pi4j/examples/build
    test mcp23017 with mcp23017 pi4j example
    sudo java -classpath .:classes:/opt/pi4j/lib/’*’ MCP23017GpioExample
    add openhab in GPIO group
    sudo adduser openhabian gpio
    you may be install i2c-tool
    sudo apt-get install i2c-tools
    sudo adduser openhabian i2c
    S 5 run raspi-config to enable i2c, serial
    Sudo raspi-config -> interfacing Options -> enable i2c và serial
    S 6 creat file mcp23017.items
    Group All
    Group Tests (All)
    Contact Test1 “Test 1” (Tests) { mcp23017="{ address:21, pin:‘A0’, mode:‘DIGITAL_INPUT’}" }
    Switch Test2 “Test 2” (Tests) { mcp23017="{ address:20, pin:‘B1’, mode:‘DIGITAL_OUTPUT’, defaultState:‘LOW’}" }
    Switch Test3 “Test 3” (Tests) { mcp23017="{ address:20, pin:‘B2’, mode:‘DIGITAL_OUTPUT’, defaultState:‘LOW’}" }
    Switch Test4 “Test 4” (Tests) { mcp23017="{ address:20, pin:‘B3’, mode:‘DIGITAL_OUTPUT’, defaultState:‘LOW’}" }
    Switch Test5 “Test 5” (Tests) { mcp23017="{ address:20, pin:‘B4’, mode:‘DIGITAL_OUTPUT’, defaultState:‘LOW’}" }
    Switch Test6 “Test 6” (Tests) { mcp23017="{ address:20, pin:‘B5’, mode:‘DIGITAL_OUTPUT’, defaultState:‘LOW’}" }
    S 7 : work with opehab panel

Hello thetrung,

Can you help me, is my first time in openhab, us MCP23017 with 8 x OUT and 8 x IN, with I2C all command work, will introduce in OH2, but I fail at the install Manual.

Have install Pi4J, but dont understand the next step’s :

compiler
javac -classpath .:classes:/opt/pi4j/lib/’’ …
run
sudo java -classpath .:classes:/opt/pi4j/lib/’
’ …

Which command I must put ?, Can you help me, please

Best Regards,

Hi @bodyfix,

you need this steps, to run pi4j examples. This commands build them. This may be need, if you try to figure out why pi4j can not talk to mcp23017. If binding works as expected, no pi4j installation is required.

Kind regards,

Alexander.

Hello,

in “Bundle:list” the mcp23017 is installed
181 | Installed | 80 | 1.9.0 | openHAB mcp23017 Binding

Active does not have to be?

Sorry for my stupid questions but it is my first time with OH.

Where do I go now these lines ?

S 6 creat file mcp23017.items
Group All
Group Tests (All)
Contact Test1 “Test 1” (Tests) { mcp23017="{ address:21, pin:‘A0’, mode:‘DIGITAL_INPUT’}" }
Switch Test2 “Test 2” (Tests) { mcp23017="{ address:20, pin:‘B1’, mode:‘DIGITAL_OUTPUT’, defaultState:‘LOW’}" }

Hi @bodyfix,

Binding should have Active state. Try “bundle:start 181” in karaf console. If it’s still inactive, take a look into log: “log:display”. May be you need install “openHAB 1.x Compatibility Layer”. Place mcp23017.items file into /etc/openhab2/items directory, assuming you use Raspberry.

Kind regards,

Alexander.

you must creat mcp23017.items ( note its .items file) file and add all your items on it
then you coppy it on etc/openhab/items folder

hi
you go teminal and run command
sudo java -classpath .:classes:/opt/pi4j/lib/’*’ MCP23017GpioExample

Hello,

Unfortunately have the next problem :frowning:

my Step’s

pi@myrpi2:/opt/pi4j/examples$ javac -cp .:classes:/opt/pi4j/lib/’*’ MCP23017GpioExample.java
pi@myrpi2:/opt/pi4j/examples$ sudo java -classpath .:classes:/opt/pi4j/lib/’*’ MCP23017GpioExample
<–Pi4J–> MCP23017 GPIO Example … started.
Unable to determine hardware version. I see: Hardware : BCM2835
,

  • expecting BCM2708 or BCM2709.
    If this is a genuine Raspberry Pi then please report this
    to projects@drogon.net. If this is not a Raspberry Pi then you
    are on your own as wiringPi is designed to support the
    Raspberry Pi ONLY.

I2ctools was installed
sudo adduser pi gpio
sudo adduser pi i2c

but after finish the items script, see in the log Error Access privileged !?

[ERROR] [org.openhab.binding.mcp23017 ] - [org.openhab.binding.mcp23017.binding(4)] Error during instantiation of the implementation object
java.lang.RuntimeException: ERROR; Access to GPIO pins on this system requires priviliged access.
at com.pi4j.wiringpi.GpioUtil.enableNonPrivilegedAccess(Native Method)
at org.openhab.binding.mcp23017.internal.MCP23017Binding.(MCP23017Binding.java:83)

[WARN ] [org.openhab.binding.mcp23017 ] - FrameworkEvent WARNING - org.openhab.binding.mcp23017
org.osgi.framework.ServiceException: org.apache.felix.scr.impl.manager.SingleComponentManager.getService() returned a null service object
at org.eclipse.osgi.internal.serviceregistry.ServiceFactoryUse.factoryGetService(ServiceFactoryUse.java:232)[org.eclipse.osgi-3.10.101.v20150820-1432.jar:]

Which right should now be set ?