MQTT
MQTT (Message Queuing Telemetry Transport) is a lightweight, publish-subscribe network protocol that is designed for sending data from Internet of Things (IoT) devices. It is particularly well-suited for communication between devices with limited resources, such as microcontrollers, sensors, and embedded systems. The MQTT integration uses a combination of push and pull. When data is published by a device the last received data is stored. This can either be imported immediately or it can be imported at scheduled times.
Datasource
Create a new secret and set the field type
to mqtt
. Enter the MQTT host and optionally a username and password if the MQTT server needs authentication. Create a field topic
and enter the name of the topic to subscribe to:
Scheduled import
Create a new connector and enter the name of the secrets in the field Datasource
. Create a new Object
and map the topic to the MQTT topic, in this case office/room_112
. Create a key to map the value of the topic and add a key time
to use the time that the topic was updated. If no field time
is specified the current time at the moment of import is used, which may be later than the time that the data was received. Click on test
to check the data is imported.
You can now set a schedule for importing the date, for example Every minute
. This means that data is imported every minute regardless of the frequency that the MQTT data is received. This prevents that large amounts of logging data is created when an MQTT device publishes at high frequency and also prevents data overload. Scheduled imports are suitable for data that does not change frequencly, such as room temperature or humidity.
Immediate import
To immediately process incoming data you can set the schedule to Continuous
. In this case the connector is run immediately when data is published to the topic and subtopics specified in the datasource. This option is most suited for device input that needs immediate action such as intrusion detection devices.
Testing
To test the connector you can use a MQTT client to publish data.
mosquitto_pub
mosquitto_pub -h [HOST] -u [USERNAME] -P [PASSWORD] -t 'office/room_112/temperature' -m 19
mosquitto_pub -h [HOST] -u [USERNAME] -P [PASSWORD] -t 'office/room_112/humidity' -m 30