MQTT template

MQTT template configuration

By selecting the MQTT type of device among the available template types, the filelds required for the communication and creation of devices are shown.

Projects, Topic where publish data and Topic where it's possible to recieve informations from Databoom can be customized by the user to form the topics to use for configurating MQTT client.

As example, consider MQTT as project, data as publication topic and info as subscription topic, the so-formed topic will be shown in thei:

  • MQTT/<unique arbitrary value>/data
  • MQTT/<unique arbitrary value>/info

The <unique arbitrary value> is a value chosen by the user that must be unique on the platform because it will be used, along with the user namespace, to form the MQTT client id (ClientId).  The <unique arbitrary value> will be also used, along with the template token, as token for the generated device following the structure <template token>-<unique arbitrary value>

It is possible to assign more topics to a single template by editing the Project part of the address and keeping the rest unchanged. 

Considering the previous example, it is possible to add other topics to a template like

  • Test/<unique arbitrary value>/data
  • Test/<unique arbitrary value>/info

Note that only the project part is changed, the rest is the same of other topics. 

Transmitting to a template

Once all the configuration fields of a template are set, it is possible to begin communication and therefore devices generation.

Data format to use too forward data to the piblication topic (MQTT/<unique arbitrary value>/data in the example) is the following:

{
    "type": "data",
    "message":  [
      {
        "template": "<MQTT template token>",
        "date": "2018-04-12T15:00:00.000Z",
        "signals": [
          {
            "name": "<signal 1 token>",
            "value": <signal 1 value>
          },
          {
            "name": "<signal 2 token>",
            "value": <signal 2 value>
          }
        ]
      }
    ]
}

Data publication implies:

  • If there weren't previous communications, the creation of a new device with the token <template token>-<unique arbitrary value> where:
    • <template token> is inside the message and corresponds to the reference template;
    • <unique arbitrary value> is extracted from the ClientId.
    The device will be populated withe the same signals of the template (new signals with the same tokens), regardless their values being sent or less. The signals are already validated and ready to communicate. If signals contains signals not appearing in the template, they're added only to the device, waiting for validation;
  • If there were previous communications, the update of <template token>-<unique arbitrary value> with values in signals. If a new signal has been added to the template, it is also created in the device;
  •  message is an array, is therefore possible to create/communicate with more devices per publication, provided that they refer to different devices.
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.