hassio-addons/addon-mqtt-io

RuntimeError: This module can only be run on a Raspberry Pi!

Closed this issue ยท 12 comments

Freshly installed HA on RPI4 crashes:

[19:47:39] INFO: Starting MQTT IO...
2024-01-07 19:47:44 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/raspberrypi.py", line 25, in setup_module
import RPi.GPIO as gpio # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/RPi/GPIO/init.py", line 23, in
from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "/usr/lib/python3.11/site-packages/mqtt_io/main.py", line 115, in
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/raspberrypi.py", line 25, in setup_module
import RPi.GPIO as gpio # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/RPi/GPIO/init.py", line 23, in
from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!
[19:47:44] INFO: Service MQTT IO exited with code 1 (by signal 0

My config file:

mqtt:
host: core-mosquitto
port: 1883
user: ""
password: "
"
topic_prefix: ha
ha_discovery:
enabled: yes

gpio_modules:

  • name: rpi
    module: raspberrypi

#digital_outputs:

- name: dioda_1

module: rpi

pin: 1

digital_inputs:

  • name: ogrod
    module: rpi
    pin: 0
    pullup: no
  • name: wejscie
    module: rpi
    pin: 1
    pullup: no
  • name: garaz
    module: rpi
    pin: 2
    pullup: no
  • name: alarm
    module: rpi
    pin: 3
    pullup: no

Any help?

Same error here, was working before. After updating HA to 2024.1 things stopped working.

Add-on version: 0.4.0
You are running the latest version of this add-on.
System: Home Assistant OS 11.3 (aarch64 / raspberrypi4-64)
Home Assistant Core: 2024.1.2
Home Assistant Supervisor: 2023.12.0

Please, share the above information when looking for help
or support in, e.g., GitHub, forums or the Discord chat.

s6-rc: info: service base-addon-banner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service base-addon-log-level: starting
s6-rc: info: service fix-attrs successfully started
Log level is set to DEBUG
s6-rc: info: service base-addon-log-level successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service mqtt-io: starting
s6-rc: info: service mqtt-io successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
[20:19:02] INFO: Starting MQTT IO...
2024-01-07 20:19:08 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/raspberrypi.py", line 25, in setup_module
import RPi.GPIO as gpio # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/RPi/GPIO/init.py", line 23, in
from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!
Traceback (most recent call last):
File "", line 198, in _run_module_as_main
File "", line 88, in _run_code
File "/usr/lib/python3.11/site-packages/mqtt_io/main.py", line 115, in
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/raspberrypi.py", line 25, in setup_module
import RPi.GPIO as gpio # type: ignore
^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/lib/python3.11/site-packages/RPi/GPIO/init.py", line 23, in
from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!

Same Problem

Tryed to
Remove & reinstall -> not working
Remove & reboot & reinstall -> not working
Changed Config: removed gpio_modules & digital_outputs -> running
Changed Config: removed digital_outputs -> running with message (yes expected)
Config did not validate due to errors in the following sections:
gpio_modules:
rpi:

  • GPIO module 'rpi' does not have any digital_input or digital_output configs

My System
Core 2024.1.2
Supervisor 2023.12.0
Operating System 11.3
Frontend 20240104.0

My mqtt-io/config.yml:

mqtt:
  host: ha-home
  port: 1883
  user: "mqtt"
  password: "mqtt"
  topic_prefix: mqtt-io/ha-home/gpio

  ha_discovery:
    enabled: yes

gpio_modules:
  - name: rpi
    module: raspberrypi

digital_outputs:
  - name: usbcharger
    module: rpi
    pin: 26


My Error Log

s6-rc: info: service s6rc-oneshot-runner: starting
s6-rc: info: service s6rc-oneshot-runner successfully started
s6-rc: info: service base-addon-banner: starting

-----------------------------------------------------------
 Add-on: MQTT IO
 Expose GPIO modules and digital sensors via MQTT for remote control and monitoring.
-----------------------------------------------------------
 Add-on version: 0.4.0
 You are running the latest version of this add-on.
 System: Home Assistant OS 11.3  (aarch64 / raspberrypi4-64)
 Home Assistant Core: 2024.1.2
 Home Assistant Supervisor: 2023.12.0
-----------------------------------------------------------
 Please, share the above information when looking for help
 or support in, e.g., GitHub, forums or the Discord chat.
-----------------------------------------------------------
s6-rc: info: service base-addon-banner successfully started
s6-rc: info: service fix-attrs: starting
s6-rc: info: service base-addon-log-level: starting
s6-rc: info: service fix-attrs successfully started
s6-rc: info: service base-addon-log-level successfully started
s6-rc: info: service legacy-cont-init: starting
s6-rc: info: service legacy-cont-init successfully started
s6-rc: info: service mqtt-io: starting
s6-rc: info: service mqtt-io successfully started
s6-rc: info: service legacy-services: starting
s6-rc: info: service legacy-services successfully started
[14:56:00] INFO: Starting MQTT IO...
2024-01-09 14:56:05 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/raspberrypi.py", line 25, in setup_module
    import RPi.GPIO as gpio  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/RPi/GPIO/__init__.py", line 23, in <module>
    from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!
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/raspberrypi.py", line 25, in setup_module
    import RPi.GPIO as gpio  # type: ignore
    ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/RPi/GPIO/__init__.py", line 23, in <module>
    from RPi._GPIO import *
RuntimeError: This module can only be run on a Raspberry Pi!
[14:56:05] INFO: Service MQTT IO exited with code 1 (by signal 0)
s6-rc: info: service legacy-services: stopping
...

The most falling apart plugin. If it doesn't update, it stops working. Version 0.4.0 I have the same problem as the guys above. Don't touch him already, let him work as he worked.

Yeah, well, I'm gonna go build my own mqttio plugin, with blackjack and hookers.

Here the same error in a similar addon. The error only occurs in HA OS 11.3 or 11.4.
The HA Core/HA Supervisor versions are not relevant. After downgrading to HA OS 11.2 everything works.

Thanks @gmoelter for the tip on downgrading HA OS

I have workaround/hack with mqtt-io addon 0.4.0 after downgrading to HA OS 11.2 and turning off protection mode on the plugin settings

# ha os update --version 11.2

There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues.
Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment ๐Ÿ‘
This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!

The Problem is still there,
This Plug-in is still crashing, maybe the Problem is in the HA OS.
I could temporary use the older System but that is not an permanent Solution
MfG

Today i have installed the new Version of HomeAssistant OS, but the problem ist still the same :(
Core 2024.3.0
Supervisor 2024.03.0
Operating System 12.1
Frontend 20240306.0

The Plugin Version MQTT IO
Current version: 0.4.0

The RPi.GPIO library should be updated [https://github.com/home-assistant/operating-system/issues/3094].

The RPi.GPIO library should be updated [https://github.com/home-assistant/operating-system/issues/3094].

Feel free to report it there. Be aware there weren't any updates since 2022: https://sourceforge.net/projects/raspberry-gpio-python/

There hasn't been any activity on this issue recently, so we clean up some of the older and inactive issues.
Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by leaving a comment ๐Ÿ‘
This issue has now been marked as stale and will be closed if no further activity occurs. Thanks!

I just fixed this bug in my fork of RPi.GPIO: https://github.com/mrk-its/raspberry-gpio-python, and put following line in addon's mqtt-io/requirements.txt:

RPi.GPIO @ git+https://github.com/mrk-its/raspberry-gpio-python