MQTT Gateway connects to an MQTT broker to receive messages. Broker configuration is stored in the database and can be updated without restarting the service.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/gsampallo/MQTTGateway/llms.txt
Use this file to discover all available pages before exploring further.
Broker connection settings
MQTT broker configurations are stored in themqtt_servers table in the database. The gateway automatically selects the enabled broker with the highest priority.
Server selection logic
When the gateway starts, it loads the MQTT server using this query:is_default=True, then by lowest id.
Server parameters
MQTT broker hostname or IP address.Example:
192.168.0.137MQTT broker port number.Common ports:
1883- Standard MQTT8883- MQTT over TLS
1883Optional username for MQTT broker authentication.Leave empty if the broker doesn’t require authentication.
Optional password for MQTT broker authentication.Leave empty if the broker doesn’t require authentication.
Whether this MQTT server configuration is active.Set to
false to disable without deleting the configuration.Whether this is the default MQTT server.When multiple enabled servers exist, the gateway uses the one marked as default.
Authentication
If your MQTT broker requires authentication, set bothusername and password fields:
Connection parameters
The MQTT client connection is configured using environment variables:Unique client identifier for the MQTT connection.See environment variables for details.
Keepalive interval in seconds for maintaining the MQTT connection.See environment variables for details.
Connection establishment
The gateway establishes the MQTT connection at startup:Topic subscriptions
The gateway automatically subscribes to MQTT topics based on enabled flows in the database.Initial subscription
When the connection is established, the gateway subscribes to all topics from enabled flows:Dynamic subscription updates
The gateway periodically reloads flows from the database and updates subscriptions:The reload interval is controlled by the
FLOWS_RELOAD_INTERVAL_SECONDS environment variable (default: 600 seconds).Topic matching
The gateway supports MQTT wildcard patterns in topic subscriptions:+- Single-level wildcard (matches one topic level)#- Multi-level wildcard (matches zero or more topic levels)
sensors/temperature- Exact matchsensors/+/temperature- Matchessensors/kitchen/temperature,sensors/bedroom/temperaturesensors/#- Matches all topics undersensors/