MCP23017 Error

Hi guys,

I am have followed the instructions giving on the openhab website to install and configure mcp23017.
I have already installed the wiringpi library and tested by command lines [ This part is working.]. I have also install pi4j but still cannot get it to work into openhab. Below is the trace error:

Error
2019-05-11 21:38:52.961 [ERROR] [nal.common.AbstractInvocationHandler] - An error occurred while calling method ‘ThingHandler.handleCommand()’ on ‘org.openhab.binding.mcp23017.handler.Mcp23017Handler@46d970’: null
java.lang.NullPointerException: null
at com.pi4j.io.gpio.impl.GpioControllerImpl.provisionPin(GpioControllerImpl.java:545) ~[?:?]
at com.pi4j.io.gpio.impl.GpioControllerImpl.provisionDigitalOutputPin(GpioControllerImpl.java:717) ~[?:?
at org.openhab.binding.mcp23017.handler.Mcp23017PinStateHolder.initializeOutputPin(Mcp23017PinStateHolder.java:71) ~[?:?]
at org.openhab.binding.mcp23017.handler.Mcp23017PinStateHolder.getOutputPin(Mcp23017PinStateHolder.java:59) ~[?:?]
at org.openhab.binding.mcp23017.handler.Mcp23017Handler.handleOutputCommand(Mcp23017Handler.java:108) ~[?:?]
at org.openhab.binding.mcp23017.handler.Mcp23017Handler.handleCommand(Mcp23017Handler.java:80) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [102:org.eclipse.smarthome.core:0.10.0.oh240]
at org.eclipse.smarthome.core.internal.common.InvocationHandlerSync.invoke(InvocationHandlerSync.java:59) [102:org.eclipse.smarthome.core:0.10.0.oh240]
at com.sun.proxy.$Proxy138.handleCommand(Unknown Source) [239:org.openhab.binding.mcp23017:2.4.0]
at org.eclipse.smarthome.core.thing.internal.profiles.ProfileCallbackImpl.handleCommand(ProfileCallbackImpl.java:75) [109:org.eclipse.smarthome.core.thing:0.10.0.oh240]
at org.eclipse.smarthome.core.thing.internal.profiles.SystemDefaultProfile.onCommandFromItem(SystemDefaultProfile.java:49) [109:org.eclipse.smarthome.core.thing:0.10.0.oh240]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:?]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:?]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:?]
at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:153) [102:org.eclipse.smarthome.core:0.10.0.oh240]
at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:53) [102:org.eclipse.smarthome.core:0.10.0.oh240]
at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:?]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]
at java.lang.Thread.run(Thread.java:748) [?:?]

Please advice.
Thanks you.

Probably a configuration error. Hard to say since you didn’t post your configuration.
You should pull a debug log to get a better idea of what’s causing the problem.

HI
I came across the same issue. Have you resolved yours?

OH2.5.1
MCP23017 Binding 2.4

.things

Thing mcp23017:mcp23017:shutter_1_8   "MCP23017_test52" [address=24,bus=1] {
   Type output_pin : output#A0 [default_state="LOW", active_low="n"]}

.items

Switch shutter_1_up "shutter_1_ up" {channel="mcp23017:mcp23017:shutter_1_8:output#A0"}

regards
T

You should’ve started a new thread for this.

But you should update to the latest version of the binding and then, if you’re still seeing an error, you should provide the details here.

I’m aware that MCP23017 2.5.2 was released. I tried to run it but there are some errors (found confirmation on https://github.com/openhab/openhab-addons/issues/6111 ), so I’ve installed 2.4 but faced the same problem as described here. If you can’t help, ok, understand.

I can’t help because you haven’t provided any information I can use to help you.
If you can provide a debug log that contains the scenario, that would be a good start.

I removed all configured things, items and started again from scratch

  1. adding thing
Thing mcp23017:mcp23017:shutter_1_8   "MCP23017 shutter 1_8" [address=24,bus=1] {
      Type output_pin : output#A0 [default_state="LOW", active_low="n"]
    Type output_pin : output#A1 [default_state="HIGH", active_low="n"]  
}

log

2020-03-02 21:41:34.694 [hingStatusInfoChangedEvent] - 'mcp23017:mcp23017:shutter_1_8' changed from UNINITIALIZED to INITIALIZING

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

2020-03-02 21:41:34.713 [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 <==

2020-03-02 21:41:34.726 [hingStatusInfoChangedEvent] - 'mcp23017:mcp23017:shutter_1_8' changed from INITIALIZING to ONLINE

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

2020-03-02 21:41:34.726 [ERROR] [ome.core.thing.link.ThingLinkManager] - Exception occurred while informing handler: null

java.lang.NullPointerException: null

	at com.pi4j.io.gpio.impl.GpioControllerImpl.provisionPin(GpioControllerImpl.java:545) ~[?:?]

	at com.pi4j.io.gpio.impl.GpioControllerImpl.provisionDigitalOutputPin(GpioControllerImpl.java:717) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017PinStateHolder.initializeOutputPin(Mcp23017PinStateHolder.java:71) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017PinStateHolder.getOutputPin(Mcp23017PinStateHolder.java:59) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017Handler.handleOutputCommand(Mcp23017Handler.java:110) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017Handler.handleCommand(Mcp23017Handler.java:79) ~[?:?]

	at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.channelLinked(BaseThingHandler.java:191) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017Handler.channelLinked(Mcp23017Handler.java:221) ~[?:?]

	at org.eclipse.smarthome.core.thing.link.ThingLinkManager.lambda$0(ThingLinkManager.java:267) ~[?:?]

	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_222]

	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_222]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_222]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_222]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]

	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]
  1. adding items
Switch shutter_1_up "shutter_1_up" {channel="mcp23017:mcp23017:shutter_1_8:output#A0"}
Switch shutter_1_down "shutter_1_ down" {channel="mcp23017:mcp23017:shutter_1_8:output#A1"}
2020-03-02 21:46:01.786 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'DOM.items'

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

2020-03-02 21:46:01.816 [.ItemChannelLinkAddedEvent] - Link 'shutter_1_up-mcp23017:mcp23017:shutter_1_8:output#A0' has been added.

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

2020-03-02 21:46:01.818 [ERROR] [ome.core.thing.link.ThingLinkManager] - Exception occurred while informing handler: null

java.lang.NullPointerException: null

	at com.pi4j.io.gpio.impl.GpioControllerImpl.provisionPin(GpioControllerImpl.java:545) ~[?:?]

	at com.pi4j.io.gpio.impl.GpioControllerImpl.provisionDigitalOutputPin(GpioControllerImpl.java:717) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017PinStateHolder.initializeOutputPin(Mcp23017PinStateHolder.java:71) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017PinStateHolder.getOutputPin(Mcp23017PinStateHolder.java:59) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017Handler.handleOutputCommand(Mcp23017Handler.java:110) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017Handler.handleCommand(Mcp23017Handler.java:79) ~[?:?]

	at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.channelLinked(BaseThingHandler.java:191) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017Handler.channelLinked(Mcp23017Handler.java:221) ~[?:?]

	at org.eclipse.smarthome.core.thing.link.ThingLinkManager.lambda$0(ThingLinkManager.java:267) ~[?:?]

	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_222]

	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_222]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_222]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_222]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]

	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]

2020-03-02 21:46:01.827 [ERROR] [ome.core.thing.link.ThingLinkManager] - Exception occurred while informing handler: null

java.lang.NullPointerException: null

	at com.pi4j.io.gpio.impl.GpioControllerImpl.provisionPin(GpioControllerImpl.java:545) ~[?:?]

	at com.pi4j.io.gpio.impl.GpioControllerImpl.provisionDigitalOutputPin(GpioControllerImpl.java:717) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017PinStateHolder.initializeOutputPin(Mcp23017PinStateHolder.java:71) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017PinStateHolder.getOutputPin(Mcp23017PinStateHolder.java:59) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017Handler.handleOutputCommand(Mcp23017Handler.java:110) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017Handler.handleCommand(Mcp23017Handler.java:79) ~[?:?]

	at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.channelLinked(BaseThingHandler.java:191) ~[?:?]

	at org.openhab.binding.mcp23017.handler.Mcp23017Handler.channelLinked(Mcp23017Handler.java:221) ~[?:?]

	at org.eclipse.smarthome.core.thing.link.ThingLinkManager.lambda$0(ThingLinkManager.java:267) ~[?:?]

	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_222]

	at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_222]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180) [?:1.8.0_222]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293) [?:1.8.0_222]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_222]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_222]

	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_222]

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

2020-03-02 21:46:01.821 [.ItemChannelLinkAddedEvent] - Link 'shutter_1_down-mcp23017:mcp23017:shutter_1_8:output#A1' has been added.

Thx for help.

That’s better, but it’s not a debug log. You need to set the logging for the binding to DEBUG mode. That will allow us to see these lines of ouput:

    initializeOutputPin for channel {}
    initializing for pinState {}
    Bound digital output for PIN: {}, channel: {}, pinState: {}

Activity sequence

  1. removing thing, items
  2. reboot
  3. setting log: debug
  4. adding things

log

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

2020-03-03 13:32:58.157 [hingStatusInfoChangedEvent] - 'mcp23017:mcp23017:shutter_1_8' changed from UNINITIALIZED to INITIALIZING

2020-03-03 13:32:58.172 [hingStatusInfoChangedEvent] - 'mcp23017:mcp23017:shutter_1_8' changed from INITIALIZING to ONLINE

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

2020-03-03 13:32:58.170 [WARN ] [.core.thing.binding.BaseThingHandler] - BaseThingHandler.initialize() will be removed soon, ThingStatus can be set manually via updateStatus(ThingStatus.ONLINE)

2020-03-03 13:32:58.177 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - channel linked mcp23017:mcp23017:shutter_1_8:output#A1

2020-03-03 13:32:58.180 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - Defined channel in group: output. Valid: true

2020-03-03 13:32:58.182 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - Is channel A1 in supported channels: true

2020-03-03 13:32:58.184 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - Received command: REFRESH on channelGroup output on channel A1

2020-03-03 13:32:58.186 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - Defined channel in group: output. Valid: true

2020-03-03 13:32:58.188 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - Is channel A1 in supported channels: true

2020-03-03 13:32:58.190 [DEBUG] [23017.handler.Mcp23017PinStateHolder] - Getting output pin for channel mcp23017:mcp23017:shutter_1_8:output#A1

2020-03-03 13:32:58.209 [DEBUG] [23017.handler.Mcp23017PinStateHolder] - initializeOutputPin for channel mcp23017:mcp23017:shutter_1_8:output#A1

2020-03-03 13:32:58.214 [DEBUG] [23017.handler.Mcp23017PinStateHolder] - initializing for pinState HIGH

2020-03-03 13:32:58.249 [ERROR] [ome.core.thing.link.ThingLinkManager] - Exception occurred while informing handler: null

java.lang.NullPointerException: null
  1. adding items
2020-03-03 14:23:15.105 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'DOM.items'

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

2020-03-03 14:23:15.139 [.ItemChannelLinkAddedEvent] - Link 'shutter_1_up-mcp23017:mcp23017:shutter_1_8:output#A0' has been added.

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

2020-03-03 14:23:15.137 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - channel linked mcp23017:mcp23017:shutter_1_8:output#A0

2020-03-03 14:23:15.144 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - Defined channel in group: output. Valid: true

2020-03-03 14:23:15.146 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - Is channel A0 in supported channels: true

2020-03-03 14:23:15.148 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - Received command: REFRESH on channelGroup output on channel A0

2020-03-03 14:23:15.150 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - Defined channel in group: output. Valid: true

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

2020-03-03 14:23:15.153 [.ItemChannelLinkAddedEvent] - Link 'shutter_1_down-mcp23017:mcp23017:shutter_1_8:output#A1' has been added.

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

2020-03-03 14:23:15.158 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - Is channel A0 in supported channels: true

2020-03-03 14:23:15.160 [DEBUG] [23017.handler.Mcp23017PinStateHolder] - Getting output pin for channel mcp23017:mcp23017:shutter_1_8:output#A0

2020-03-03 14:23:15.163 [DEBUG] [23017.handler.Mcp23017PinStateHolder] - initializeOutputPin for channel mcp23017:mcp23017:shutter_1_8:output#A0

2020-03-03 14:23:15.167 [DEBUG] [23017.handler.Mcp23017PinStateHolder] - initializing for pinState LOW

2020-03-03 14:23:15.170 [DEBUG] [ing.mcp23017.handler.Mcp23017Handler] - channel linked mcp23017:mcp23017:shutter_1_8:output#A1

2020-03-03 14:23:15.170 [ERROR] [ome.core.thing.link.ThingLinkManager] - Exception occurred while informing handler: null

java.lang.NullPointerException: null

Try this version.
I added some new debug output.

The result below, still negative :frowning:
I checked
/boot/config.txt: dtparam=i2c_arm=on
openhabian is a member of 997(gpio),998(i2c) groups

Have you got any other ideas?
Thx in advance

2020-03-04 23:21:37.995 [INFO ] [el.core.internal.ModelRepositoryImpl] - Refreshing model 'dom.things'

2020-03-04 23:21:38.073 [DEBUG] [3017.internal.Mcp23017HandlerFactory] - Trying to create handler for mcp23017:mcp23017

2020-03-04 23:21:38.080 [DEBUG] [3017.internal.Mcp23017HandlerFactory] - Handler match for mcp23017:mcp23017

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

2020-03-04 23:21:38.095 [hingStatusInfoChangedEvent] - 'mcp23017:mcp23017:shutter_1_8' changed from UNINITIALIZED to INITIALIZING

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

2020-03-04 23:21:38.111 [DEBUG] [017.internal.handler.Mcp23017Handler] - initializing mcp provider for busNumber 1 and address 36

2020-03-04 23:21:38.119 [DEBUG] [017.internal.handler.Mcp23017Handler] - got mcpProvider null

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

2020-03-04 23:21:38.122 [hingStatusInfoChangedEvent] - 'mcp23017:mcp23017:shutter_1_8' changed from INITIALIZING to OFFLINE (CONFIGURATION_ERROR): Tried to access not available I2C bus: null

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

2020-03-04 23:21:38.133 [DEBUG] [017.internal.handler.Mcp23017Handler] - channel linked mcp23017:mcp23017:shutter_1_8:output#A1

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

2020-03-04 23:21:38.134 [hingStatusInfoChangedEvent] - 'mcp23017:mcp23017:shutter_1_8' changed from OFFLINE (CONFIGURATION_ERROR): Tried to access not available I2C bus: null to ONLINE

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

2020-03-04 23:21:38.140 [DEBUG] [017.internal.handler.Mcp23017Handler] - Defined channel in group: output. Valid: true

2020-03-04 23:21:38.145 [DEBUG] [017.internal.handler.Mcp23017Handler] - Is channel A1 in supported channels: true

2020-03-04 23:21:38.150 [DEBUG] [017.internal.handler.Mcp23017Handler] - Received command: REFRESH on channelGroup output on channel A1

2020-03-04 23:21:38.159 [DEBUG] [017.internal.handler.Mcp23017Handler] - Defined channel in group: output. Valid: true

2020-03-04 23:21:38.164 [DEBUG] [017.internal.handler.Mcp23017Handler] - Is channel A1 in supported channels: true

This would be a different error than you were getting before. Check to see if it goes away after a while (or after a few restarts).

Still the same :frowning:
Restarting, rebooting didn’t fix the problem.

Sorry I can not help you with this problem. But I can tell you that openhab 2.5 and MCP binding 2.4 is working fine on my system. Binding 2.5 is not working. Only for your information

I am just wondering about the output parameter “active low”. I never used it. And the documentation mentioned “default_state” as additional parameter only. Only the example shows the “active low”. Maybe you should try it without this parameter.