I want to register custom measurement templates via MQTT

Hi,

to create a SR2 template you need to publish to s/ut/<template_ID> with a payload of request and response templates denoted by message IDs 10 and 11 respectively. To create a measurement request template you need to follow this notation:

10,msgId,method,api,response,type,time,<n custom property triples>

Where always contains three parameters that define a single value in the output data. The parameters are path, type, value exactly in that order.
An example for a template with one fragment and three series would be like this:

10,100,POST,MEASUREMENT,,my_type,,my_fragment.myseries.value,NUMBER,,my_fragment.myseries2.value,NUMBER,,my_fragment.myseries3.value,NUMBER,

This leaves the time and the three declared values empty, meaning they must be supplied as payload when using this template. Time is also optional in SR2 and can be set on server side if not otherwise present. This means in use when sending data with this template the payload looks like this:

100,,1,2,3

This creates a measurement like this for the connected MQTT device:

{
  "my_fragment": {
    "myseries": {
      "value": 1
    },
    "myseries2": {
      "value": 2
    },
    "myseries3": {
      "value": 3
    }
  },
  "time": "<server time at the time of arrival>",
  ...
}

You can find our public documentation about the topic here: SmartREST - Cumulocity IoT Guides