flyte / mqtt-io

Expose GPIO modules (Raspberry Pi, Beaglebone, PCF8754, PiFace2 etc.) and digital sensors (LM75 etc.) to an MQTT server for remote control and monitoring.
MIT License
472 stars 159 forks source link

MCP23017 module not starting in mqtt-io Add-on #358

Open jfiger opened 8 months ago

jfiger commented 8 months ago

Describe the bug The initialization of the MCP23017 module failed. see dump below
Config


mqtt:
  host:  *redacted*
  port: 1883

gpio_modules:
  - name: mcp
    module: mcp23017
    chip_addr: 0x20

digital_inputs:
  - name: hallway_frontdoor
    module: mcp
    pin: 14
    inverted: false
    pullup: true
    retain: true
    ha_discovery:
      component: binary_sensor
      name: Hallway Frontdoor
19:57:10] INFO: Starting MQTT IO...
s6-rc: info: service legacy-services successfully started
2024-03-20 19:57:17 mqtt_io.__main__ [ERROR] MqttIo crashed!
Traceback (most recent call last):
  File "/usr/lib/python3.11/site-packages/mqtt_io/__main__.py", line 107, in main
    mqtt_gpio.run()
  File "/usr/lib/python3.11/site-packages/mqtt_io/server.py", line 1269, in run
    self._init_gpio_modules()
  File "/usr/lib/python3.11/site-packages/mqtt_io/server.py", line 244, in _init_gpio_modules
    self.gpio_modules[gpio_config["name"]] = _init_module(
                                             ^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/mqtt_io/server.py", line 128, in _init_module
    return module_class(module_config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/mqtt_io/modules/gpio/__init__.py", line 106, in __init__
    self.setup_module()
  File "/usr/lib/python3.11/site-packages/mqtt_io/modules/gpio/mcp23017.py", line 40, in setup_module
    import board  # type: ignore
    ^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/board.py", line 22, in <module>
    from adafruit_blinka.agnostic import board_id, detector
  File "/usr/lib/python3.11/site-packages/adafruit_blinka/agnostic/__init__.py", line 21, in <module>
    chip_id = detector.chip.id
              ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/adafruit_platformdetect/chip.py", line 423, in __getattr__
    raise AttributeError()  # Avoid infinite recursion
    ^^^^^^^^^^^^^^^^^^^^^^
AttributeError
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/usr/lib/python3.11/site-packages/mqtt_io/__main__.py", line 115, in <module>
    main()
  File "/usr/lib/python3.11/site-packages/mqtt_io/__main__.py", line 107, in main
    mqtt_gpio.run()
  File "/usr/lib/python3.11/site-packages/mqtt_io/server.py", line 1269, in run
    self._init_gpio_modules()
  File "/usr/lib/python3.11/site-packages/mqtt_io/server.py", line 244, in _init_gpio_modules
    self.gpio_modules[gpio_config["name"]] = _init_module(
                                             ^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/mqtt_io/server.py", line 128, in _init_module
    return module_class(module_config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/mqtt_io/modules/gpio/__init__.py", line 106, in __init__
    self.setup_module()
  File "/usr/lib/python3.11/site-packages/mqtt_io/modules/gpio/mcp23017.py", line 40, in setup_module
    import board  # type: ignore
    ^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/board.py", line 22, in <module>
    from adafruit_blinka.agnostic import board_id, detector
  File "/usr/lib/python3.11/site-packages/adafruit_blinka/agnostic/__init__.py", line 21, in <module>
    chip_id = detector.chip.id
              ^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/adafruit_platformdetect/chip.py", line 423, in __getattr__
    raise AttributeError()  # Avoid infinite recursion
    ^^^^^^^^^^^^^^^^^^^^^^
AttributeError
[19:57:18] INFO: Service MQTT IO exited with code 1 (by signal 0)

Hardware

System:

BenjiU commented 8 months ago

Looks like, that it is an issue in the adafruit lib with newer python libs: https://github.com/adafruit/Adafruit_Python_PlatformDetect/issues/342