[SOLVED] MCP23017 attributes gone when restart or reboot fhem

Begonnen von claudio, 03 Dezember 2021, 22:03:37

Vorheriges Thema - Nächstes Thema

claudio

Hi guys

I am implementing some additionnal IO for my alarm system. I use the MCP 23017 IO expander with I2c on a raspi 4.

I just found out a bug with the attributes of the I2C_MCP23017 device. I can register them and they are saved within the config but when I restart fhem or the pi itself, most of the attributes are gone, except theses:

Attributes:
   OnStartup  A0=last
   room       TESTS


I tried on 2 computers with latest fhem updates applied, same result.

Seen this thread with similar issue:

https://forum.fhem.de/index.php/topic,122862.msg1173907.html#msg1173907


Theses are my declarations:

Internals:
   DEF        18
   EXCEPT_FD  32
   FUUID      61a9fab7-f33f-d74b-e7eb-ce51a38c882b4987
   GPIO_Basedir /sys/class/gpio
   GPIO_Nr    18
   NAME       raspi_pin_12
   NR         159
   STATE      on
   TYPE       RPI_GPIO
   WiringPi_gpio /usr/bin/gpio
   lasttrg    1638564412.6707
   READINGS:
     2021-12-03 12:41:57   Counter         13
     2021-12-03 21:46:52   Dblclick        off
     2021-12-03 21:46:53   Longpress       on
     2021-12-03 21:46:52   Pinlevel        high
     2021-12-03 21:46:52   state           on
     2021-12-03 21:46:53   test            egal
   fhem:
     interfaces switch
Attributes:
   active_low yes
   direction  input
   interrupt  both
   pud_resistor up
   room       TESTS
   userReadings test {fhem ("get raspi_mcp23017");; "egal" }



Internals:
   DEF        0x20
   FUUID      61aa0f3e-f33f-d74b-93b8-6d95ee83eb918931
   I2C_Address 32
   IODev      raspi_i2c_1
   NAME       raspi_mcp23017
   NR         161
   STATE      Ok
   TYPE       I2C_MCP23017
   raspi_i2c_1_SENDSTAT Ok
   READINGS:
     2021-12-03 21:19:30   IODev           raspi_i2c_1
     2021-12-03 20:55:06   PortA0          off
     2021-12-03 20:48:53   PortA1          off
     2021-12-03 20:55:07   PortA2          off
     2021-12-03 20:55:07   PortA3          off
     2021-12-03 20:55:07   PortA4          off
     2021-12-03 20:48:53   PortA5          off
     2021-12-03 20:48:49   PortA6          off
     2021-12-03 21:18:19   PortA7          off
     2021-12-03 21:17:46   PortB0          off
     2021-12-03 20:56:47   PortB1          off
     2021-12-03 20:55:07   PortB2          off
     2021-12-03 20:55:07   PortB3          off
     2021-12-03 20:55:07   PortB4          off
     2021-12-03 20:55:07   PortB5          off
     2021-12-03 20:55:07   PortB6          off
     2021-12-03 21:20:34   PortB7          off
     2021-12-03 21:49:24   state           Ok
Attributes:
   Interrupt  B0,B1,B2,B3,B4,B5,B6,B7
   InterruptOut separate_active-high
   OnStartup  A0=last
   OutputPorts A0,A1,A2,A3,A4,A5,A6,A7
   Pullup     B0,B1,B2,B3,B4,B5,B6,B7
   invert_input B0,B1,B2,B3,B4,B5,B6,B7
   room       TESTS



claudio

update:

SAME problem with the module I2C_MCP23008, it also loose it's settings attributes after a restart or reboot

tried also the the module I2C_PCF8574, which appear to work as expected

klausw

very strange, i tried your configuration (due to the lack of an MCP23017 without hardware)
after FHEM restart all attributes are still there
are you sure that you saved the configuration before reboot?
where ist raspi_i2c_1 located in fhem.cfg? Before or after raspi_mcp23017?
RasPi B v2 mit FHEM 18B20 über 1Wire, LED PWM Treiber über I2C, Luchtdruck-, Feuchtesensor und ein paar Schalter/LED\'s zum testen
Module: RPI_GPIO, RPII2C, I2C_EEPROM, I2C_MCP23008, I2C_MCP23017, I2C_MCP342x, I2C_PCA9532, I2C_PCF8574, I2C_SHT21, I2C_BME280

Frank_Huber

Hi,
I use this Module since 6 years on 4 Raspberrys.
Never habe seen such an issue.
So I would also expect you missed to save.
Br
Frank

claudio

#4
Zitat von: klausw am 06 Dezember 2021, 16:24:50
very strange, i tried your configuration (due to the lack of an MCP23017 without hardware)
after FHEM restart all attributes are still there
are you sure that you saved the configuration before reboot?
where ist raspi_i2c_1 located in fhem.cfg? Before or after raspi_mcp23017?

Hi

I'm 100% sure that I saved the config each time, moreover, the attributes are present in fhem.cfg but doesn't appear in the interface...

For the tests (in a VM), I've downloaded a fresh fhem.deb from the site and updated it. The config is vanilla. I then added a FRM device, then the I2C_MCP23017 entry. Saved at each changes. Finally, I added output port as attributes and saved.
Made a fhem restart, the attributes are gone in fhem but as you can see in the video, they are indeed present in fhem.cfg



claudio

I think I've found the problem:

the IOdev MUST ALSO be in the attributes, if it doesn't, the attributes are not restored on restart. But they are indeed saved in the .cfg file

Internals:
   DEF        0x20
   FUUID      61aa0f3e-f33f-d74b-93b8-6d95ee83eb918931
   I2C_Address 32
   IODev      raspiI2C
   NAME       raspi_mcp23017
   NR         156
   STATE      Ok
   TYPE       I2C_MCP23017
   raspiI2C_SENDSTAT Ok
   READINGS:
     2016-11-03 18:17:11   IODev           raspiI2C
     2016-11-03 18:18:33   PortA0          off
     2016-11-03 18:18:31   PortA1          off
     2016-11-03 18:18:29   PortA2          off
     2016-11-03 18:18:26   PortA3          off
     2016-11-03 18:18:24   PortA4          off
     2016-11-03 18:18:22   PortA5          off
     2016-11-03 18:18:17   PortA6          off
     2021-12-08 23:06:36   PortA7          off
     2021-12-08 23:06:36   PortB0          off
     2021-12-08 19:33:01   PortB1          off
     2016-11-03 18:17:58   PortB2          off
     2016-11-03 18:18:01   PortB3          off
     2016-11-03 18:18:03   PortB4          off
     2016-11-03 18:18:05   PortB5          off
     2016-11-03 18:18:08   PortB6          off
     2016-11-03 18:18:11   PortB7          off
     2021-12-08 23:06:49   state           Ok
Attributes:
   IODev      raspiI2C
   Interrupt  A0,A1,A2,A3,A4,A5,A6,A7,B0,B1,B2,B3,B4,B5,B6,B7
   InterruptOut connected_active-high
   Pullup     A0,A1,A2,A3,A4,A5,A6,A7,B0,B1,B2,B3,B4,B5,B6,B7
   invert_input A0,A1,A2,A3,A4,A5,A6,A7,B0,B1,B2,B3,B4,B5,B6,B7
   room       TESTS


Frank_Huber

Zitat von: claudio am 08 Dezember 2021, 23:19:25
I think I've found the problem:
the IOdev MUST ALSO be in the attributes, if it doesn't, the attributes are not restored on restart. But they are indeed saved in the .cfg file
morning Claudio,

you mean it is exactly as written in fat in the C-Ref? ;-)
https://fhem.de/commandref.html#I2C_MCP23017

but sorry, we should have seen that from your first post. the IOdev was missing there already.

br
Frank

claudio

Zitat von: Frank_Huber am 09 Dezember 2021, 08:30:05
morning Claudio,

you mean it is exactly as written in fat in the C-Ref? ;-)
https://fhem.de/commandref.html#I2C_MCP23017

but sorry, we should have seen that from your first post. the IOdev was missing there already.

br
Frank

;) Although I've read the commandref, I've missed that one... the thing is when testing, the missing attribute didn't cause any problem, it's just when fhem is restarted. That was confusing.. 8)

And the fact that when I2C_MCP23017 is declared before RPII2C in fhem.cfg, it didn't work either.

Thanks you anyway for your help  :-*


klausw

Zitat von: Frank_Huber am 09 Dezember 2021, 08:30:05
morning Claudio,

you mean it is exactly as written in fat in the C-Ref? ;-)
https://fhem.de/commandref.html#I2C_MCP23017

but sorry, we should have seen that from your first post. the IOdev was missing there already.

br
Frank

hmm i forgot why i wrote these information in bold letters, now its back ;)
But its not a good solution. At least the attributes shall stay there.
I'll have a look on it.
RasPi B v2 mit FHEM 18B20 über 1Wire, LED PWM Treiber über I2C, Luchtdruck-, Feuchtesensor und ein paar Schalter/LED\'s zum testen
Module: RPI_GPIO, RPII2C, I2C_EEPROM, I2C_MCP23008, I2C_MCP23017, I2C_MCP342x, I2C_PCA9532, I2C_PCF8574, I2C_SHT21, I2C_BME280