Problem with new MCP23017 binding in Openhab 2.3

(Michal Szymanski) #1

Yesterday I’ve started migration to 2.3 and point on my list is migration to new MCP23017 binding ( . I’ve changed my old configuration and now I perform testing.
I have to say that this binding works very unstable. Main problem what I have now is that after restart some (random) inputs does not work (or work with huge delay).

Did you notice such problem?

Michal Szymanski

(Aogorek) #2

I’m the author of this binding and I have to admit, that I started to have the same problems. I investigated it a little, and it turnes out that items file is loaded BEFORE things file, so input pins are not initialized.

I described it here:

(Michal Szymanski) #3

Today I will confirm that my problem is solved when item file is copied to Item directory after reboot. But for sure changing something in a item file (what cause reloading) does not help because I’ve tried it several times. I’ve tried to define Thing in file and in PaperUI but result is almost the same.

The funny thing is that each time some input items works and some note (even defined in the same file); Regarding to you post, how authors of other binding handle this problem?


(Aogorek) #4

Changing item file doesnt reload all items, I’ve noticed it too.
this binding isn’t typical - it has to create listener to other library - other bindings do not base on channelLinked method.
But for sure something broke recently. For me this binding worked flawlessly in 2.2.0. After upgrade to 2.3.0 problems began…

I send a question to openHab developers. Maybe they will have some idea how to fix this.

(Aogorek) #5

And how is it? Is it working?

(Michal Szymanski) #6

I perform test today. Yesterday I was involved in promoting OH in Poland :slight_smile:

Michal Szymanski

(Aogorek) #7

Looks really nice!!!

I was investigating trouble with mcp binding and it looks for me that something changed in openhab framework - some events are now asynchronous and IMHO it causes problems with my binding. I made some workaround, it is not well tested yet, but it looks like it works for me.
Here is the link for built jar:

so, uninstall default one, and copy this to /usr/share/openhab2/addons
then restart openhab.

This is ugly workaround, and I’m sure that openHab crew won’t allow me to merge it to their code, but I’ll try to start a discussion about it, so maybe It will be fixed soon

(Aogorek) #8

And i’m not sure what is your hardware config, but You may need to set input pins as PULL_UP like this:
Thing mcp23017:mcp23017:chipA “MCP23017chipA” [address=20,bus=1] {
Type input_pin : input#B0 [pull_mode=“PULL_UP”]
Type input_pin : input#B1 [pull_mode=“PULL_UP”]
Type input_pin : input#B2 [pull_mode=“PULL_UP”]
Type input_pin : input#B3 [pull_mode=“PULL_UP”]
Type input_pin : input#B4 [pull_mode=“PULL_UP”]
Type input_pin : input#B5 [pull_mode=“PULL_UP”]
Type input_pin : input#B6 [pull_mode=“PULL_UP”]


GPIO / MCP23017 contacts are NULL after reboot
(Michal Szymanski) #9

I think I do not need “Pull-up” option because I have pull-up resistor on my pcb. Previous version of MCP binding has no such option that is why I’ve added resistor to my PCB.

Today I will try your workaround. To be honest in OH during the startup I have many ERROR probably related to asynchronous behavior of OH.
For example I’ve got hundred error messages during boot that persistence does not work, usually many error that some objects are null but after several minutes situation is stable. Also at least in 2.1 not all values are recovered from mapdb simply sometime some are null my impression it is also related to asynchronous loading items/rules/persistance addson :frowning:


(Michal Szymanski) #10

I’ve uninstaled default and copied your to /usr/share… and after rebooted but where I can find configuration for this binding ? In binding list I have only old one

(Aogorek) #11

It should be visible in PaperUI in configuration/bindings.
Yesterday I made clean install of raspbian with openhab and it worked ok:

If it is not visible, check logs, maybe there is some info

GPIO / MCP23017 contacts are NULL after reboot
(Michal Szymanski) #12

ok, I’ve upgraded. I have quite complex home automation systems and it takes some time. But it seems it works.


(Michal Szymanski) #13

So far so good. I’ve found one ‘bug’ but it appeard that is not software bug but defect in switch connected to mcp23017 :slight_smile:

I still testing becuase for me it is not only tests of MCP23017 but also test of OH 2.3

Michal Szymanski

(Michal Szymanski) #14

It looks that it work. There is some issue with remembering old values of MCP inputs, but it also happened in old version. I’m not sure if ‘default’ value for output works correctly but it is also probable related to mapdb