MQTT IO - forwarding GPIO resources to HomeAssistant via mqtt-io

To forward controller resources in MQTT, you can use the " target="_blank">mqtt-io project.

The main advantage of this method is the use of Home Assistant MQTT discovery (entities will appear in HA without the need to manually write them in yaml)

Known issues and nuances:

Installation and manual launch

Getting root

$ sudo -i

Installing mqtt-io:

# pip3 install< mqtt-io

Copy the configuration file for your controller model to /etc/mqtt-io-config.yaml (don't forget to change host/user/password according to your MQTT server settings)

Before running mqtt-io you need remove export of all GPIOs in sysfs (command for a specific JetHub model is listed in the appropriate section below)

Example for JetHub D1:

# echo 436 452 453 454 455 456 462 467 469 470 471 472 | xargs -n 1 echo >/sys/class/gpio/unexport

Run mqtt-io:

# python3 -m mqtt_io /etc/mqtt -io-config.yaml

Run via systemd

We assume that mqtt-io itself and /etc/mqtt-io-config.yaml are already installed.

Launch the editor:

sudo nano /etc/systemd/system/mqtt-io.service

Copy there (If you don't have JetHub D1, then ExecStartPre should be replaced with):


ExecStartPre=sh -c "echo 436 452 453 454 455 456 462 467 469 470 471 472 | xargs -n 1 echo >/sys/class/gpio/unexport; exit 0"

ExecStart=python3 -m mqtt_io /etc/mqtt-io-config.yaml


Start the service:

sudo systemctl start mqtt-io

Check status/logs:< /p>

sudo systemctl status mqtt-io

Add to autoload:

sudo systemctl enable mqtt-io .service

View log:

sudo journalctl -u mqtt-io.service -f

Configuration files and unexport for JetHub controllers