Configuration

All options live in src/config.py. Key settings:

SettingDescription
mqtt_hostMQTT broker address
mqtt_user / mqtt_passwordMQTT credentials
mqtt_portMQTT port (default 1883, 8883 for TLS)
mqtt_tlsEnable TLS/SSL for the MQTT connection
mqtt_tls_ca_certs / mqtt_tls_insecureOptional CA file for a self-signed broker cert, or skip cert verification
mqtt_websockets / mqtt_websocket_pathConnect over MQTT-over-WebSockets (ports ~9001/8084) and its URL path
mqtt_discovery_prefixHA discovery prefix (default homeassistant)
mqtt_topic_prefixTopic prefix (default rpi-MQTT-monitor)
mqtt_uns_structureOptional UNS prefix prepended to all topics
discovery_messagesPublish HA auto-discovery config messages
service_sleep_timeSeconds between readings when running as a service
update_check_intervalSeconds between update checks (default 3600)
use_availabilityMark sensors unavailable in HA on read failure
retainSet MQTT retain flag on published messages
qosMQTT QoS level (0, 1, or 2)
languageUI language: en, de, fr, bg
ha_device_nameOverride hostname as the HA device name
hass_host / hass_tokenHome Assistant API URL and long-lived token
restart_buttonAdd a restart button to HA
shutdown_buttonAdd a shutdown button to HA
display_controlAdd display on/off buttons to HA (auto-detects backend: see below)
display_on_command / display_off_commandOptional custom commands for display control (override auto-detection)
group_messagesSend all values as a single CSV message (disables discovery)

Full configuration reference: Configuration wiki.

Interactive configurator

Run rpi-mqtt-monitor --config to edit these settings from a terminal UI instead of editing config.py by hand. Move through the settings with the ↑/↓ arrows; each shows its description and default value. Press Enter to edit the selected value, s to save, and q to quit. Comments, ordering, and formatting in config.py are preserved.

Interactive TUI configurator

Display control backends

With display_control = True, the monitor on/off buttons auto-detect a working backend for the current environment:

EnvironmentBackend used
X11 desktopxset dpms force on/off
wlroots Wayland (Pi labwc/wayfire, sway)wlr-randr --output <out> --on/--off
Raspberry Pivcgencmd display_power 1/0
GNOME / generic Waylandddcutil (DDC/CI, hardware level)

GNOME and most non-wlroots Wayland compositors expose no CLI to force monitors off, so external monitors are controlled over DDC/CI with ddcutil. When you enable display control during install.sh, the installer detects your backend and offers to perform this setup for you. To do it manually:

sudo apt install ddcutil
echo i2c-dev | sudo tee /etc/modules-load.d/i2c-dev.conf
sudo modprobe i2c-dev
sudo usermod -aG i2c $USER     # the service runs as this user; re-login or restart the service afterwards
ddcutil detect                 # confirm your monitor(s) are listed

Each monitor must have DDC/CI enabled in its on-screen (OSD) menu — some ship with it off.

If none of the above fits your setup, set display_on_command / display_off_command in config.py to any custom command, which always takes precedence over auto-detection.