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

KeyError trying to run gpiozero with digital_outputs #414

Open
arturalbov opened this issue Oct 19, 2024 · 0 comments
Open

KeyError trying to run gpiozero with digital_outputs #414

arturalbov opened this issue Oct 19, 2024 · 0 comments

Comments

@arturalbov
Copy link

arturalbov commented Oct 19, 2024

Describe the bug
I've configured a digital output pin 18 with gpiozero module and mqtt-io threw a KeyError: 18 error during start.

Expected behavior
It should run without errors.

Error messages and traceback

Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "/home/pi/mqttiove/lib/python3.11/site-packages/mqtt_io/__main__.py", line 126, in <module>
    main()
  File "/home/pi/mqttiove/lib/python3.11/site-packages/mqtt_io/__main__.py", line 118, in main
    mqtt_gpio.run()
  File "/home/pi/mqttiove/lib/python3.11/site-packages/mqtt_io/server.py", line 1449, in run
    self._init_digital_outputs()
  File "/home/pi/mqttiove/lib/python3.11/site-packages/mqtt_io/server.py", line 550, in _init_digital_outputs
    raw_value = gpio_module.get_pin(out_conf["pin"])
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/pi/mqttiove/lib/python3.11/site-packages/mqtt_io/modules/gpio/gpiozero.py", line 85, in get_pin
    return cast(bool, self._in_pins[pin].is_active)
                      ~~~~~~~~~~~~~^^^^^
KeyError: 18

Config

mqtt:
  host: test.mosquitto.org
  port: 1883
  topic_prefix: mqtt_io
  ha_discovery:
    enabled: true

gpio_modules:
  - name: rpi_gpio
    module: gpiozero

digital_outputs:
  - name: gpio18-2
    module: rpi_gpio
    pin: 18

Hardware

  • Platform: Raspberry Pi 5

System:

  • OS: Debian GNU/Linux 12 (bookworm)
  • Python version: 3.11.2
  • User you're running as: pi
  • Using a virtualenv?: yes

Additional context
If I change digital_outputs to digital_inputs everything works fine.
Due to logs and source code I'm guessing that get_pin(...) method is called and it fails because it only checks _in_pins map.

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

1 participant