[SOLVED] MCP23017 default state output pin after "service openhab2 restart"

openhab2
mcp23017
Tags: #<Tag:0x00007f1e68b07a38> #<Tag:0x00007f1e68b07150>
(Lorenzo S.) #1

openhab 2.4.0
i have 3 boards, they contains each 2xmcp23017 , address 20-21; 22-23, 24-25.
after a “service openhab2 restart” from cli the first board don’t start at default value state “LOW” in my case.

Instead 22-23, 24-25 perfect.
For fix the “bad” state i enter on thing’s file , mod a char, save.
Strange was only on first and second chip.

Regards Lorenzo

file.Things

Thing mcp23017:mcp23017:chip20  "MCP23017 chip 20" [address=20,bus=1] { 
    Type output_pin : output#A0 [default_state="LOW"]
    Type output_pin : output#A1 [default_state="LOW"]
    Type output_pin : output#A2 [default_state="LOW"]
    Type output_pin : output#A3 [default_state="LOW"]
    Type output_pin : output#A4 [default_state="LOW"]
    Type output_pin : output#A5 [default_state="LOW"]
    Type output_pin : output#A6 [default_state="LOW"]
    Type output_pin : output#A7 [default_state="LOW"]
        
    Type input_pin : input#B0 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B1 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B2 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B3 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B4 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B5 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B6 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B7 [pull_mode="PULL_DOWN"]
}      
Thing mcp23017:mcp23017:chip21  "MCP23017 chip 21" [address=21,bus=1] { 
    Type output_pin : output#A0 [default_state="LOW"]
    Type output_pin : output#A1 [default_state="LOW"]
    Type output_pin : output#A2 [default_state="LOW"]
    Type output_pin : output#A3 [default_state="LOW"]
    Type output_pin : output#A4 [default_state="LOW"]
    Type output_pin : output#A5 [default_state="LOW"]
    Type output_pin : output#A6 [default_state="LOW"]
    Type output_pin : output#A7 [default_state="LOW"]
        
    Type input_pin : input#B0 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B1 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B2 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B3 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B4 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B5 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B6 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B7 [pull_mode="PULL_DOWN"]
} 

Thing mcp23017:mcp23017:chip22  "MCP23017 chip 22" [address=22,bus=1] { 
    Type output_pin : output#A0 [default_state="LOW"]
    Type output_pin : output#A1 [default_state="LOW"]
    Type output_pin : output#A2 [default_state="LOW"]
    Type output_pin : output#A3 [default_state="LOW"]
    Type output_pin : output#A4 [default_state="LOW"]
    Type output_pin : output#A5 [default_state="LOW"]
    Type output_pin : output#A6 [default_state="LOW"]
    Type output_pin : output#A7 [default_state="LOW"]
        
    Type input_pin : input#B0 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B1 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B2 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B3 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B4 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B5 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B6 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B7 [pull_mode="PULL_DOWN"]
}

Thing mcp23017:mcp23017:chip23  "MCP23017 chip 23" [address=23,bus=1] {
    Type output_pin : output#A0 [default_state="LOW"]
    Type output_pin : output#A1 [default_state="LOW"]
    Type output_pin : output#A2 [default_state="LOW"]
    Type output_pin : output#A3 [default_state="LOW"]
    Type output_pin : output#A4 [default_state="LOW"]
    Type output_pin : output#A5 [default_state="LOW"]
    Type output_pin : output#A6 [default_state="LOW"]
    Type output_pin : output#A7 [default_state="LOW"]
        
    Type input_pin : input#B0 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B1 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B2 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B3 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B4 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B5 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B6 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B7 [pull_mode="PULL_DOWN"]
}

Thing mcp23017:mcp23017:chip24  "MCP23017 chip 24" [address=24,bus=1] {
    Type output_pin : output#A0 [default_state="LOW"]
    Type output_pin : output#A1 [default_state="LOW"]
    Type output_pin : output#A2 [default_state="LOW"]
    Type output_pin : output#A3 [default_state="LOW"]
    Type output_pin : output#A4 [default_state="LOW"]
    Type output_pin : output#A5 [default_state="LOW"]
    Type output_pin : output#A6 [default_state="LOW"]
    Type output_pin : output#A7 [default_state="LOW"]
        
    Type input_pin : input#B0 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B1 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B2 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B3 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B4 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B5 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B6 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B7 [pull_mode="PULL_DOWN"]
}

Thing mcp23017:mcp23017:chip25  "MCP23017 chip 25" [address=25,bus=1] {
    Type output_pin : output#A0 [default_state="LOW"]
    Type output_pin : output#A1 [default_state="LOW"]
    Type output_pin : output#A2 [default_state="LOW"]
    Type output_pin : output#A3 [default_state="LOW"]
    Type output_pin : output#A4 [default_state="LOW"]
    Type output_pin : output#A5 [default_state="LOW"]
    Type output_pin : output#A6 [default_state="LOW"]
    Type output_pin : output#A7 [default_state="LOW"]
        
    Type input_pin : input#B0 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B1 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B2 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B3 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B4 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B5 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B6 [pull_mode="PULL_DOWN"]
    Type input_pin : input#B7 [pull_mode="PULL_DOWN"]
}

0 Likes

(Lorenzo S.) #2

i solved with workaround rule
i change the default state things to high

Thing mcp23017:mcp23017:chip20  "MCP23017 chip 25" [address=25,bus=1] {
    Type output_pin : output#A0 [default_state="HIGH"]
....
rule "Init"
when
	System started
then
	//createTimer(now.plusSeconds(60)) 
	gPulse.members.filter[i|i.state==NULL].forEach[j| j.sendCommand(ON)]
	gPulsedim.members.filter[l|l.state==NULL].forEach[k| k.sendCommand(ON)]
end
0 Likes

(Jan) #3

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

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

0 Likes

(Lorenzo S.) #4

I had same issue, the solution’s name is “data persistence”. Simpler db probably is mapdb.

Hi

0 Likes

(Jan) #5

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. as I wrote earlier after readding items (contacts) in items file inputs strat to work correclty.

0 Likes