[MCP23017 Binding] Items-file configuration / Additional Parameters

Hi There,

I try to use the MPC23017-Binding. It is working so far. Now I want use the default_state und the pullup-Features of this binding. The doc[1] says something about “Additional Parameters” for the item-configuration. I have tried a lot of syntaxes, but I cant get it to work.

I’ve tried this things: Contact living_room_in “Living room in” …
{channel=“mcp23017:mcp23017:chipA:input#A7”, pull_mode=“PULL_UP”}
{channel=“mcp23017:mcp23017:chipA:input#A7:pull_mode=PULL_UP”}
{channel=“mcp23017:mcp23017:chipA:input#A7” [pull_mode=“PULL_UP”]}
{channel=“mcp23017:mcp23017:chipA:input#A7#pull_mode=PULL_UP”}

Does anybody know the correct syntax for defining this parameters?
Thank you!

Igor

[1] https://docs.openhab.org/addons/bindings/mcp23017/readme.html

I guess you have to set the pull mode in the things.

Hi Udo,

I hope your guess is wrong, because the Chip MCP23017 itselfs allows to set the internal pullup resistors per pin, and not per chip.

Also, the paper-UI allows to set the Pullup-Resistors in the Items-Parameters.
But what is the way to set it via config-file?

Thank you, Udo!
Igor

Oh, the setting wouldn’t be per thing but per channel. Please take a look at Paper UI. As I don’t have the hardware, I don’t know what the configuration is like. But as it’s a openHAB2 Binding, I think, you will get a Thing, and within the configured thing, you will be able to configure the channels. In a *.things file it would look like

Thing mcp23017:mcp23017:chipA  "MCP23017 chip A" [address=20,bus=1] {
    Channel : input#A0 [pull_mode="PULL_UP"]
}

but that’s only a guess…
On the other hand, in Paper UI there should be a parameter names pull mode… per channel.

Hi Udo,
thank you for your guessing.

It results in this log-message:
‘mcp23017:mcp23017:chipA’ changed from UNINITIALIZED to UNINITIALIZED (HANDLER_MISSING_ERROR)

Is there a way to set the log-level to “debug” or “trace”? May there are some usefull infos hidden in this levels. I just see Info and warn-Messages.

Thank you!

Igor

Hi Again,

after reading the things.xtext-File [0] I finally created this config:

Thing mcp23017:mcp23017:chipA “MCP23017 chip A” [address=20,bus=1] {
Type output : output#B0 [default_state=“HIGH”]
Type input : input#A7 [pull_mode=“PULL_UP”]
}

but this results in the error-messages below… I have no clue what to do… please help!

Thank you!
Igor

[0] https://github.com/eclipse/smarthome/blob/master/bundles/model/org.eclipse.smarthome.model.thing/src/org/eclipse/smarthome/model/thing/Thing.xtext

2018-05-07 19:02:36.686 [ERROR] [.thing.internal.GenericThingProvider] - Channel type mcp23017:output could not be resolved.

2018-05-07 19:02:36.698 [ERROR] [.thing.internal.GenericThingProvider] - Channel type mcp23017:input could not be resolved.

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

2018-05-07 19:02:36.890 [hingStatusInfoChangedEvent] - ‘mcp23017:mcp23017:chipA’ changed from UNINITIALIZED to INITIALIZING

2018-05-07 19:02:36.940 [hingStatusInfoChangedEvent] - ‘mcp23017:mcp23017:chipA’ changed from INITIALIZING to ONLINE

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

2018-05-07 19:02:36.995 [ERROR] [ome.core.thing.link.ThingLinkManager] - Exception occurred while informing handler: null

java.lang.NullPointerException: null

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

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

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

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

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

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

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

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

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

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) [?:?]

2018-05-07 19:02:36.995 [ERROR] [ome.core.thing.link.ThingLinkManager] - Exception occurred while informing handler: null

java.lang.NullPointerException: null

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

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

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

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

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

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

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

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

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

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) [?:?]

2018-05-07 19:02:37.094 [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.provisionPin(GpioControllerImpl.java:538) ~[?:?]

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

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

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

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

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

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

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

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

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

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) [?:?]

Did you take a look in Paper UI?

Hi Udo,

if I create the thing with the paper-UI and set the Pull-UPs in the paper-UI, it creates a config in the file

/var/lib/openhab2/jsondb/org.eclipse.smarthome.core.thing.Thing.json

with a (stripped) content like this:

{
“mcp23017:mcp23017:chipA”: {
“class”: “org.eclipse.smarthome.core.thing.internal.ThingImpl”,
“value”: {
“label”: “mcp23017”,
“channels”: [
[… cut a lot of channels … ]
{
“acceptedItemType”: “Contact”,
“kind”: “STATE”,
“uid”: {
“segments”: [
“mcp23017”,
“mcp23017”,
“chipA”,
“input#A7”
]
},
“channelTypeUID”: {
“segments”: [
“mcp23017”,
“input_pin”
]
},
“label”: “Input pin”,
“description”: “channel type for MCP23017 pin in DIGITAL_INPUT mode (contact)”,
“configuration”: {
“properties”: {
“pull_mode”: “PULL_UP”
}
},
“properties”: {},
“defaultTags”: []
},

I’ll play a little with this values in the things-file and give you the results.

Udo, Thank you!

Have a nive evening,
Igor

This is the json statement, but what is displayed in Paper UI? what are the config pages like?

Hi Udo,

finally, after a lot of fuckup, i’ve got it to work, in some way…

the working configuration is:

Thing mcp23017:mcp23017:chipA  "MCP23017 chip A" [address=20,bus=1] {
        Type output_pin : output#B0 [default_state="HIGH"]
        Type input_pin : input#A7 [pull_mode="PULL_UP"]
}

The output-default-state seems to be working with this config.
But the Pull-up-config for the input-pin is blocked by a sourcecode-bug in the MCP23017handler-Implementation. I’ve fixed it by replacing the code with the hot-deployment from the Remote-Debugger. There is an Patch append to this thread.

Questions:

  1. What is the way to add my config to the doc-page? (https://docs.openhab.org/addons/bindings/mcp230171/readme.html)
  2. Is there a way to cntribute my patch (one-liner) without Github-Account?

Cheers,
Igor

diff --git a/addons/binding/org.openhab.binding.mcp23017/src/main/java/org/openhab/binding/mcp23017/handler/Mcp23017Handler.java b/addons/binding/org.openhab.binding.mcp23017/src/main/java/org/openhab/binding/mcp23017/handler/Mcp23017Handler.java
index d4a3aac..4f41dc7 100644
--- a/addons/binding/org.openhab.binding.mcp23017/src/main/java/org/openhab/binding/mcp23017/handler/Mcp23017Handler.java
+++ b/addons/binding/org.openhab.binding.mcp23017/src/main/java/org/openhab/binding/mcp23017/handler/Mcp23017Handler.java
@@ -158,7 +158,7 @@
         Pin pin = PinMapper.get(channel.getIdWithoutGroup());
 
         String pullMode = DEFAULT_PULL_MODE;
-        if (thing.getChannel(channel.getIdWithoutGroup()) != null) {
+        if (thing.getChannel(channel.getId()) != null) {
             Configuration configuration = thing.getChannel(channel.getId()).getConfiguration();
             pullMode = ((String) configuration.get(PULL_MODE)) != null ? ((String) configuration.get(PULL_MODE))
                     : DEFAULT_PULL_MODE;

No, you have to create an issue + pull request (with signed-off-by) and you need an account for this. But it’s really easy to use github :slight_smile: