Problem with new MCP23017 binding in Openhab 2.3

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

Michal Szymanski

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:
https://drive.google.com/open?id=1Mdw6jyxxpRb48CCF1wGOrljRQw5_56it

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

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”]

}

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

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

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

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

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

Michal

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

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

Hello.
Do you know if there is mcp23018 binding as well?
McP 23017 allows you to address only 8 devices over i2c while 23017 has got 8 bits address so you can manage 128 devices in i2c.
Many thanks.
Massimo

Sorry I do not know, you mean 8 23017 devices = 8*16 inputs/outputs.

Hello Guys, I am Marcin from Gdynia and just starting home automaton project with OH.

I was trying to implement MCP23017 last year without success and because I/O expanders were most important I stopped my project. I wasn’t able to find the reason why I can set outputs states manually by python commands and cannot set them by OH2. I read many of conversation like this but nothing helped. For now I back from beginning to this subject and installed fresh OH2.4 2 days ago. Some problems occurs with inputs when I used the Paper Interface for binding implementation so I found this conversation. I read everything and tried one more time.
I prepared new fresh installation of OH2.4 and install .jar file from Mr. Anatol. For now everything is working well, but on LOG Viewer I have on non-critical warning like below:

2018-12-31 15:31:59.843 [hingStatusInfoChangedEvent] - 'mcp23017:mcp23017:chipA' changed from UNINITIALIZED (DISABLED) to INITIALIZING

==> /var/log/openhab2/openhab.log <==

2018-12-31 15:31:59.843 **[WARN ] [.core.thing.binding.BaseThingHandler] - BaseThingHandler.initialize() will be removed soon, ThingStatus can be set manually via updateStatus(ThingStatus.ONLINE)**

==> /var/log/openhab2/events.log <==

2018-12-31 15:31:59.852 [hingStatusInfoChangedEvent] - 'mcp23017:mcp23017:chipA' changed from INITIALIZING to ONLINE

Is it anything which I should worry about?

Hi please contact with me directly in Polish. I’m using OH 2.3 with MCP without any problem and I think I have not such warning.

Michal

Hi guys
I would like to ask if Binding MCP23017 work correclty after reboot or OH2 restart your projects?

I have opehab2.4.0 on openhabian and after restart all mcp23017 inputs are not initialized.
I have to remove all releated input items from items file save it and than readd them back in order to initialize. But even though input states are not read until I toglle them.

All outputs work correctly.

Thanks

I use 2.3 version and sometimes thera are some issues with values after initialization.
First question do you use persistance to store values for input/outpu, by default openHab does not remember old values.

Michal

Hi

I use influxdb for persistance, but after oh2 restart or rpi reboot mcp inputs dont work at all. If I togle input nothing is chnged in sitemap or habpanel no log entry either. as I wrote earlier after readding items (contacts) in items file inputs strat to work correclty.

As I wrote above from time to time I have problem with storing old value but I’ve notice that some time ago I’ve changed influxdb to mapdb for storing old values used when startup happen = restoreOnStartup. I do not remember exactly but I’ve read somewhere that is better to use mapdb for such restoreOnStartup

Example line:
MainWaterValve : strategy = everyChange, restoreOnStartup

Hello,

This issue still persist even in openhab 2.5 snapshot. There is no issue if Paper UI used.
Piece from the log:
[INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘mcp23107.items’
[INFO ] [el.core.internal.ModelRepositoryImpl] - Loading model ‘mcp23017.things’

Hello

I’ve ported this to MCP23008, works as expected under 2.4.0, it does not work for restoring output values on startup, I’ve removed all rule files just to exclude possibility that some rules are firing on events during startup and setting values:

2019-10-18 08:17:43.263 [hingStatusInfoChangedEvent] - 'mcp23017:mcp23017:relayboard1' changed from UNINITIALIZED to INITIALIZING                                                                   
2019-10-18 08:17:43.340 [hingStatusInfoChangedEvent] - 'mcp23017:mcp23017:relayboard1' changed from INITIALIZING to ONLINE
....
2019-10-18 08:17:46.833 [vent.ItemStateChangedEvent] - SW_HeatSource changed from NULL to ON                                                                                                      
2019-10-18 08:17:46.835 [vent.ItemStateChangedEvent] - SW_HeatSource_Manual changed from NULL to ON

I can see the items switched on on Paper UI, when I toggle them manualy to off and on again, the relay is switching, but it is not switched on persistence restore.

Does someone have working output values on restore please?

Not sure if this is a bug of this binding or of core ?

Thank you

Jan

Can I ask you to post sample of working mcp23017.things DSL syntaxe please? I do not like configuring things using Paper UI and had troubles with loading things file…

Thank you in advance

Jan