In the following configuration, the activation of the Mqtt-Io add-on fails due to a hardware exception when accessing GPIO. What can I do?
Add-on: MQTT IO
Expose GPIO modules and digital sensors via MQTT for remote control and monitoring.
Add-on version: 0.3.0
You are running the latest version of this add-on.
System: Home Assistant OS 11.2 (aarch64 / raspberrypi4-64)
Home Assistant Core: 2023.12.3
Home Assistant Supervisor: 2023.11.6
The Mqtt-Io configuration file is as follows:
mqtt:
host: localhost
topic_prefix: home
gpio_modules:
name: rpi
module: raspberrypi
digital_inputs:
name: gpio0
module: rpi
pin: 11
digital_outputs:
name: gpio0
module: rpi
pin: 12
Here are the relevant info of the log file:
File “/usr/lib/python3.11/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!
File “/usr/lib/python3.11/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!
[12:17:52] INFO: Service MQTT IO exited with code 1 (by signal 0)
This is likely by design. HAOS is a locked-down version of Linux to improve security, and Add-ons run in docker containers. The underlying HAOS is unlikely to allow access to the ‘real’ hardware (hence the root permission errors).
The alternative I used was to move fron RPi GPIO to an ESP8266 (Wemos D1 mini) running ESPhome or Tasmota. You could also try moving from HAOS to your own install of Linux plus HASS container, but that’s a lot more work, and defeats the object of a packaged secure image.
I carefully read the answer, in the meantime I continued with tests.
On some occasion, Hassos’s GUI can deceive. It is possible to give access privileges to the HW. In Settings-> Add-ons-> MQTT IO, when authorized the following writing appears