27 September 2018
The MQTT command can be used to publish MQTT messages or subscribe to an MQTT topic given an MQTT server. The MQTT command has to be issued in order to be able to receive MQTT notifications. While publishing a message to an MQTT server is synchronous, messages received from the MQTT on the subscribed topic are asynchronous.
| Command | Required Parameters | Required Corrade Permissions | Example |
|---|---|---|---|
MQTT | group, password, action | bridge | |
| Parameter | Possible Value | Sub-Parameter | Possible Value | Description | Example | |
|---|---|---|---|---|---|---|
action | publish | host | An IP address | Publish a message to an MQTT server. | | |
port | A port number. | |||||
topic | A topic to send the message to. | |||||
payload | A message payload. | |||||
username | The username and password to use for authentication to the MQTT server. | |||||
secret | ||||||
type | Set to either text or binary. | |||||
QoS | Quality of service level (defaults to 0). |
|||||
retain | Whether to retain the message (defaults to False). |
|||||
subscribe | host | An IP address | Subscribe to a topic from an MQTT server. | | ||
port | A port number. | |||||
topic | A topic to send the message to. | |||||
username | The username and password to use for authentication to the MQTT server. | |||||
secret | ||||||
execute | True or False (default, False) | Whether to execute commands sent to the topic that Corrade subscribes to. | ||||
notifications | A list of notifications. | Publish the requested notifications on the MQTT topic that Corrade subscribes to. | ||||
URL | Optionally bind an MQTT notification for the subscription. | |||||
type | Set to either text or binary. |
|||||
QoS | Quality of service level (defaults to 0). |
|||||
ID | An UUID used to track the binding (generated randomly by default). | |||||
unsubscribe | session | An MQTT subscription UUID | Unsubscribe from an MQTT server topic. | | ||
URL | Optionally remove the MQTT notification. | |||||
list | List all MQTT subscriptions for the calling group | |
MQTT command call. UUIDs of existing subscriptions can be shown by issuing the MQTT command with the action parameter set to list.State folder and is read at Corrade startup and saved after a successful subscription to an MQTT topic.URL parameter when invoking the MQTT command with the action parameter set to subscribe will have the effect of additionally binding a Corrade notification for the MQTT subscription (and the notification tag set to the ID parameter value). When interfacing via Corrade's HTTP server or when scripting with LSL passing the URL parameter can thus spare the need to issue a follow-up notify command in order to be able to receive the messages from the MQTT server. This requires the mqtt notification to be enabled for the configured group or an error will be returned when attempting to subscribe to an MQTT topic.