Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash using gpiod #350

Open
1 task done
rtfmjoey opened this issue Feb 26, 2024 · 1 comment
Open
1 task done

Crash using gpiod #350

rtfmjoey opened this issue Feb 26, 2024 · 1 comment

Comments

@rtfmjoey
Copy link

rtfmjoey commented Feb 26, 2024

Describe the bug
Followed the documentation to install mqtt-io and configured module:

gpio_modules:
  - name: c2
    module: gpiod
    chip: /dev/gpiochip1

Starting mqtt-io results in the following error:

root@odroidc2:~# python3 -m mqtt_io config.yml
2024-02-26 11:55:45 mqtt_io.__main__ [ERROR] MqttIo crashed!
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/__main__.py", line 107, in main
    mqtt_gpio.run()
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/server.py", line 1269, in run
    self._init_gpio_modules()
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/server.py", line 244, in _init_gpio_modules
    self.gpio_modules[gpio_config["name"]] = _init_module(
                                             ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/server.py", line 128, in _init_module
    return module_class(module_config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/modules/gpio/__init__.py", line 106, in __init__
    self.setup_module()
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/modules/gpio/gpiod.py", line 35, in setup_module
    self.chip = gpiod.chip(self.config["chip"])
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'module' object is not callable
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/local/lib/python3.11/dist-packages/mqtt_io/__main__.py", line 115, in <module>
    main()
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/__main__.py", line 107, in main
    mqtt_gpio.run()
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/server.py", line 1269, in run
    self._init_gpio_modules()
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/server.py", line 244, in _init_gpio_modules
    self.gpio_modules[gpio_config["name"]] = _init_module(
                                             ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/server.py", line 128, in _init_module
    return module_class(module_config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/modules/gpio/__init__.py", line 106, in __init__
    self.setup_module()
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/modules/gpio/gpiod.py", line 35, in setup_module
    self.chip = gpiod.chip(self.config["chip"])
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'module' object is not callable

Expected behavior
mqtt-io starts normally

Error messages and traceback

root@odroidc2:~# python3 -m mqtt_io config.yml
2024-02-26 11:55:45 mqtt_io.__main__ [ERROR] MqttIo crashed!
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/__main__.py", line 107, in main
    mqtt_gpio.run()
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/server.py", line 1269, in run
    self._init_gpio_modules()
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/server.py", line 244, in _init_gpio_modules
    self.gpio_modules[gpio_config["name"]] = _init_module(
                                             ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/server.py", line 128, in _init_module
    return module_class(module_config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/modules/gpio/__init__.py", line 106, in __init__
    self.setup_module()
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/modules/gpio/gpiod.py", line 35, in setup_module
    self.chip = gpiod.chip(self.config["chip"])
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'module' object is not callable
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/local/lib/python3.11/dist-packages/mqtt_io/__main__.py", line 115, in <module>
    main()
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/__main__.py", line 107, in main
    mqtt_gpio.run()
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/server.py", line 1269, in run
    self._init_gpio_modules()
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/server.py", line 244, in _init_gpio_modules
    self.gpio_modules[gpio_config["name"]] = _init_module(
                                             ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/server.py", line 128, in _init_module
    return module_class(module_config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/modules/gpio/__init__.py", line 106, in __init__
    self.setup_module()
  File "/usr/local/lib/python3.11/dist-packages/mqtt_io/modules/gpio/gpiod.py", line 35, in setup_module
    self.chip = gpiod.chip(self.config["chip"])
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'module' object is not callable

Config

mqtt:
  host: 192.168.10.30
  topic_prefix: odroid_meterkast
  ha_discovery:
    enabled: yes
    name: odroid_meterkast

gpio_modules:
  - name: c2
    module: gpiod
    chip: /dev/gpiochip1

digital_inputs:
  - name: watermeter_pulse1
    module: c2
    pin: 78

Hardware
Odroid C2, trying to use simple in/outputs

System:

  • OS: Armbian 24.2.1 Bookworm CLI
  • Python version: Python 3.11.2
  • User you're running as: root
  • Using a virtualenv?: no
@CromFr
Copy link

CromFr commented Jun 3, 2024

I believe mqtt-io depends on an old version of gpiod. Running pip install "gpiod<2.0.0" solved this issue for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants