MQTT Connector

Connecting MQTT broker to a Waylay Broker

Prerequisites

  • Access to MQTT broker
  • Waylay Broker url

One possible MQTT deployment models is presented on the picture below (where industrial GW terminates MQTT):

alt text

Configuring MQTT service connector

The MQTT service connector allows you to bridge MQTT broker with your Waylay environment fairly easy!

All one needs to do is to download this service connector as a Docker image and run it with a file that contains the environment variables.

The command for running the docker is as followed:

docker run -p 3000:3000 --rm --name connector --env-file=PathToFile/connectorFile mqttIoTConnectorDockerImage

Create a file and insert the configurable variables listed below.

Configuration settings

The following environment variables have to be configured:

Var Default Description
PORT 3000 Port
PARSE_MODE Flattening JSON objects or not (value can be ‘flat’ or not filled in)
RESOURCE_PROPERTY_NAME resource Name of the message key that Waylay will use as resource name
MQTT_TOPICS List of Topics to connect to (seperated by ;)
MQTT_CONNECTION_STRING MQTT broker endpoint url
MQTT_USERNAME MQTT broker username
MQTT_PASSWORD MQTT broker password
MQTT_PORT MQTT broker port
TENANT_ID TenantId of your organisation
APPLICATION_SECRET Secret of your application
APPLICATION_ID Id of your application
AUTH_URL Waylay accounts url (Same URL as configured in Broker)
BROKER_URL URL of your broker

PARSE_MODE


This will convert nested JSON objects into flat (key, value) objects so that all metric are stored in the timeseries database.

value : PARSE_MODE='flat' or not specified

MQTT_TOPICS


List of Topics for the MQTT connector to use, if the list contains more than 1 it must be seperated by ; Example:

MQTT_TOPICS='topic1;/topic2'

RESOURCE_PROPERTY_NAME


Messages flowing trough the MQTT connector must contain a specified ‘resource’ key that will be stored in the Waylay Environment.

Example:

{ "resource": "resource1", "temperature": 12, "humidity": 24 }

RESOURCE_PROPERTY_NAME can be specified to use another key instead.

Example:

RESOURCE_PROPERTY_NAME='device'

MQTT_CONNECTION_STRING


Endpoint url of your MQTT broker

MQTT_USERNAME


Username of your MQTT broker.

MQTT_PASSWORD


Password of your MQTT broker.

MQTT_PORT


Port of your MQTT broker.