hassio-addons/addon-mqtt-io

MQTT IO not starting - no access to /dev/mem

Closed this issue · 3 comments

Problem/Motivation

Hi, I have installed it as a plugin but I'm not able to start the MQTT IO on managed HA (Home Assistant OS 9.5) on RPI:

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.2.1
 You are running the latest version of this add-on.
 System: Home Assistant OS 9.5  (aarch64 / raspberrypi4-64)
 Home Assistant Core: 2023.4.5
 Home Assistant Supervisor: 2023.04.1
-----------------------------------------------------------
 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
[11:19:58] INFO: Starting MQTT IO...
2023-04-26 11:20:07 mqtt_io.__main__ [ERROR] MqttIo crashed!
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/mqtt_io/__main__.py", line 107, in main
    mqtt_gpio.run()
  File "/usr/lib/python3.10/site-packages/mqtt_io/server.py", line 1240, in run
    self._init_digital_inputs()
  File "/usr/lib/python3.10/site-packages/mqtt_io/server.py", line 387, in _init_digital_inputs
    gpio_module.setup_pin_internal(PinDirection.INPUT, in_conf)
  File "/usr/lib/python3.10/site-packages/mqtt_io/modules/gpio/__init__.py", line 208, in setup_pin_internal
    return self.setup_pin(
  File "/usr/lib/python3.10/site-packages/mqtt_io/modules/gpio/raspberrypi.py", line 56, in setup_pin
    self.io.setup(pin, direction, pull_up_down=pullup, initial=initial_int)
RuntimeError: No access to /dev/mem.  Try running as root!
Traceback (most recent call last):
  File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/usr/lib/python3.10/site-packages/mqtt_io/__main__.py", line 115, in <module>
    main()
  File "/usr/lib/python3.10/site-packages/mqtt_io/__main__.py", line 107, in main
    mqtt_gpio.run()
  File "/usr/lib/python3.10/site-packages/mqtt_io/server.py", line 1240, in run
    self._init_digital_inputs()
  File "/usr/lib/python3.10/site-packages/mqtt_io/server.py", line 387, in _init_digital_inputs
    gpio_module.setup_pin_internal(PinDirection.INPUT, in_conf)
  File "/usr/lib/python3.10/site-packages/mqtt_io/modules/gpio/__init__.py", line 208, in setup_pin_internal
    return self.setup_pin(
  File "/usr/lib/python3.10/site-packages/mqtt_io/modules/gpio/raspberrypi.py", line 56, in setup_pin
    self.io.setup(pin, direction, pull_up_down=pullup, initial=initial_int)
RuntimeError: No access to /dev/mem.  Try running as root!
[11:20:07] INFO: Service MQTT IO exited with code 1 (by signal 0)
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service mqtt-io: stopping
s6-rc: info: service mqtt-io successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service base-addon-log-level: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service base-addon-log-level successfully stopped
s6-rc: info: service base-addon-banner: stopping
s6-rc: info: service base-addon-banner successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped

Expected behavior

MQTT starts

Actual behavior

mqtt_io.main [ERROR] MqttIo crashed! -> RuntimeError: No access to /dev/mem. Try running as root!

Hi I’ve been having the same issue, looking to create a basic relay control with MQTT-io but I keep getting errors around no access:

RuntimeError: No access to /dev/mem. Try running as root!

I am running hassio on pi4 and looked into installing the addon via terminal but I can’t find installation instructions for installing with hassio, furthermore normal linux commands (like sudo or apt) dont seem to work. Can i change permissions on hassio somehow?

I can control the gpio’s with the raspberry pi gpio integration so pin control is being granted somehow.

gpio_modules:
    name: gate
    module: raspberrypi

digital_outputs:
    name: relay
    module: gate
    pin: 11    #17 and GPIO_17 also attempted
    on_payload: “ON”
    off_payload: “OFF
```”

Hi I’ve been having the same issue, looking to create a basic relay control with MQTT-io but I keep getting errors around no access:

RuntimeError: No access to /dev/mem. Try running as root!

I am running hassio on pi4 and looked into installing the addon via terminal but I can’t find installation instructions for installing with hassio, furthermore normal linux commands (like sudo or apt) dont seem to work. Can i change permissions on hassio somehow?

I can control the gpio’s with the raspberry pi gpio integration so pin control is being granted somehow.

gpio_modules:
    name: gate
    module: raspberrypi

digital_outputs:
    name: relay
    module: gate
    pin: 11    #17 and GPIO_17 also attempted
    on_payload: “ON”
    off_payload: “OFF
```”

Forget this project here, it's nothing for people which runs HA with Hassio. I use this here to control the GPIOs:

https://github.com/thecode/ha-rpi_gpio#manual-installation

Works perfectly!

The trick is, that it's not starting an additional container, like it's the case for "plugins", which would not have root permissions.

Ah thats a shame, was hoping to use this as the gpio integration has some limitations for my application. Reading previous issues on the it seems that changing the installation config file (mqtt-io/config.yaml ) to

devices:

  • /dev/mem

see #46 (comment)

seems like it could be solved but not sure how rebuild the addon, spent ages looking through the OS too see if anything could be edited but no luck