Table of Contents

MQTT Integration

MQTT is an open standard messaging protocol for the Internet of Things (IoT). It is designed as an extremely lightweight publish/subscribe messaging transport that is ideal for connecting remote devices with a small code footprint and minimal network bandwidth (source: https://mqtt.org).

MQTT stands for Message Queuing Telemetry Transport.

The core elements of an MQTT system are clients and servers (also known as brokers).

Clients subscribe to topics to publish and receive messages. This means that a client handles the roles of subscriber and publisher.

Servers run topics, for example receive subscriptions from clients on topics, or messages from clients and forward them based on client’s subscriptions, to interested clients.

A Thinknx server can be configured to work as an MQTT client to connect to an external broker/server and subscribe to one or multiple topics, or as an MQTT server itself to handle subscriptions and topics distribution.

 MQTT overview

Figure: MQTT Overview

MQTT Client

Permits the configuration of the Thinknx device as MQTT client either to an external broker or to the internal one. To handle messages from MQTT Thinknx needs to be configured as client. This permits to read (as virtual input) and write (as virtual outputs) values associated to a topic and to use them inside the UI or other system objects. To permits a wide application range, values coming or going to MQTT can be pre/post processed in a Data Format Editor. Thinknx supports plain or encrypted (TLS) communication with brokers. The encrypted communication may not work properly on all the circumstances depending on the server models (very old Thinknx servers may have some difficulties) and the capabilities of the external brokers.

Virtual Inputs (Subscribers)

This section permits to subscribe for a topic and to get the updated values associated with it. The value can then be used to update UI, for the internal system objects or can be transmitted to KNX.

Data Format Editor

This window permits to configure the format of the Incoming Data and Response.

  1. First, select the incoming data format type. The data received can be XML, String, or JSON.
  2. Configure the correct response path.
  1. Cast the value received to the appropriate representation (Bit - Int - Double - Enum - String).

Virtual Outputs (Publishers)

This section permits to publish values coming from the server to a specific topic. The value can then be used by other MQTT client that will react to them. The value for these topics can come from specific KNX group addresses.

Data Format Editor

This window permits to configure the format of the sent data by the publisher.

  1. First, select the type of the Sent Data. The data sent can be XML, String, Parameters, or JSON.
  1. Cast the value sent to the appropriate representation (Bit - Int - Double - Enum - String).

Example 1: Thinknx Server as MQTT Client

A Shelly H&T humidity and temperature sensor is used in this example. This device will publish its data to an external MQTT server such as Mosquitto (https://mosquitto.org/), CloudMQTT (https://www.cloudmqtt.com/) or HiveMQ (https://www.hivemq.com/). The Thinknx server acting as an MQTT client, will subscribe to the temperature and humidity topics, and the external MQTT server will forward the values to the server.

Example 1: Thinknx server as MQTT client

Figure: Thinknx server as MQTT client

Configuration on Shelly H&T

Configuration Shelly H&T

Figure: Configuration Shelly H&T

Configuration in Thinknx configurator

To view all topics available for Shelly devices, visit their API documentation on this link: https://shelly-api-docs.shelly.cloud/gen1/#shelly-h-amp-t

Virtual Input MQTT Client

Figure: Virtual Input MQTT Client

Data Input Format

Figure: Data Input Format

To visualize the temperature value received by the Shelly device on a specific page:

Visualizing Shelly Temperature

Figure: Visualizing Shelly Temperature