MQTT
MQTT Connection
The MQTT Connection establishes a connection towards an MQTT Broker.
Settings
Besides the URL, most entries are optional if your broker allows a connection without them. An account can be used to bundle the "settings" details in one place. Select an account to use these in your connection.
URL: Enter the URL followed by the port (e.g. mqtt://mosquitto:1883). MQTT Connections support TLS. Use mqtts:// instead of MQTT:// to connect via TLS.
Username & Password: To authenticate a client within a broker, it is common to use a username and password to sign in. Different users can have different access rights to a broker.
ClientID: If you leave the ClientID empty, the broker will use a randomly generated ID every time you connect. Sometimes a username is bound to a ClientID and needs it as a further authentication method. A client connection with the broker using the same ClientID as another client will result in a kick-out of the other client.
Base Topic: You can set a base topic for your connection.
Protocol Version: There are two supported protocol versions for MQTT. Select the one your broker is using. If you don´t know leave the selection at default.
Clean: With a clean session checked, a broker will always forget a client after the connection is lost. If a client connects with a clean session unchecked, the client ID will be stored and the broker will wait for the return off that client ID. Only uncheck, if you are sure about it.
Client Certificates: Can be used as an alternative authentication step at a broker. And need the certificate and the private key to be used.
Server Certificate: Add your CA file here if necessary.
Subscriptions
In the Subscription menu set your MQTT subscriptions to certain topics, which Inbox should be subscribing and the QoS settings.
Logs
The Logs inform about the latest feedback of your endpoint. This can be successful or unsuccessful connection attempts. If you have trouble connecting, here is a good place to search for a reason.
MQTT Functions
Since the subscription to a topic is done in the settings of an MQTT connection, the only needed MQTT function is MQTT.PUBLISH(). As all stream functions, MQTT functions base on a created connection, which is always the first parameter. Use the function to publish a payload to the topic of your choice. If needed you are able to set flags like "retained", the QoS level or certain MQTT v5 properties. A new message will be published everytime the function is triggered.
The payload can be anything. Either decide to only use strings or use formats like JSON or XML.