A device can send a request to IoT Platform to obtain the Thing Specification Language (TSL) model of the device. The TSL model defines properties, services, and events of the device.

  • Request topic: /sys/{productKey}/{deviceName}/thing/dsltemplate/get
  • Response topic: /sys/{productKey}/{deviceName}/thing/dsltemplate/get_reply

Sample request in the Alink JSON format:

{
  "id": "123",
  "version": "1.0",
  "sys":{
      "ack":0
  },
  "params": {},
  "method": "thing.dsltemplate.get"
}

Sample response in the Alink JSON format:

{
  "id": "123",
  "code": 200,
  "data": {
    "schema": "https://iot-tsl.oss-cn-shanghai.aliyuncs.com/schema.json",
    "link": "/sys/1234556554/airCondition/thing/",
    "profile": {
      "productKey": "1234556554",
      "deviceName": "airCondition"
    },
    "properties": [
      {
        "identifier": "fan_array_property",
        "name": "Fan array property",
        "accessMode": "r",
        "required": true,
        "dataType": {
          "type": "array",
          "specs": {
            "size": "128",
            "item": {
              "type": "int"
            }
          }
        }
      }
    ],
    "events": [
      {
        "identifier": "alarm",
        "name": "alarm",
        "desc": "Fan alert",
        "type": "alert",
        "required": true,
        "outputData": [
          {
            "identifier": "errorCode",
            "name": "Error code",
            "dataType": {
              "type": "text",
              "specs": {
                "length": "255"
              }
            }
          }
        ],
        "method": "thing.event.alarm.post"
      }
    ],
    "services": [
      {
        "identifier": "timeReset",
        "name": "timeReset",
        "desc": "Time calibration",
        "inputData": [
          {
            "identifier": "timeZone",
            "name": "Time zone",
            "dataType": {
              "type": "text",
              "specs": {
                "length": "512"
              }
            }
          }
        ],
        "outputData": [
          {
            "identifier": "curTime",
            "name": "Current time",
            "dataType": {
              "type": "date",
              "specs": {}
            }
          }
        ],
        "method": "thing.service.timeReset"
      },
      {
        "identifier": "set",
        "name": "set",
        "required": true,
        "desc": "Set properties",
        "method": "thing.service.property.set",
        "inputData": [
          {
            "identifier": "fan_int_property",
            "name": "Integer property of the fan",
            "accessMode": "rw",
            "required": true,
            "dataType": {
              "type": "int",
              "specs": {
                "min": "0",
                "max": "100",
                "unit": "g/ml",
                "unitName": "Milliliter"
              }
            }
          }
        ],
        "outputData": []
      },
      {
        "identifier": "get",
        "name": "get",
        "required": true,
        "desc": "Get properties",
        "method": "thing.service.property.get",
        "inputData": [
          "array_property",
          "fan_int_property",
          "batch_enum_attr_id",
          "fan_float_property",
          "fan_double_property",
          "fan_text_property",
          "fan_date_property",
          "batch_boolean_attr_id",
          "fan_struct_property"
        ],
        "outputData": [
          {
            "identifier": "fan_array_property",
            "name": "Fan array property",
            "accessMode": "r",
            "required": true,
            "dataType": {
              "type": "array",
              "specs": {
                "size": "128",
                "item": {
                  "type": "int"
                }
              }
            }
          }
        ]
      }
    ]
  }
}

The following table describes the parameters.

Parameter Type Description
id String The ID of the message. Valid values: 0 to 4294967295. Each message ID must be unique for the device.
version String The version of the protocol. Valid value: 1.0.
sys Object The parameter for extended features. The value contains the fields for each feature.
Note If no extended features are configured when you use a device SDK to develop device features, this parameter is unavailable. The extended features use the default configurations.
ack Integer The extended feature field in the sys parameter. This field specifies whether IoT Platform needs to return response data for the registration request. Valid values:
  • 1: indicates that IoT Platform needs to return response data.
  • 0: indicates that IoT Platform does not need to return response data.
Note

If this feature is not configured, this parameter is unavailable. By default, IoT Platform returns response data for a registration request.

params Object Leave this parameter empty.
method String The request method. Valid value: thing.dsltemplate.get.
productKey String The key of the product to which the device belongs. Example: 1234556554.
deviceName String The name of the device. Example: airCondition.
data Object The TSL description of the device. For more information, see What is a TSL model?

The following table describes the error codes.

HTTP status code Error message Description
460 request parameter error The error message returned because one or more request parameters are invalid.
6321 tsl: device not exist in product The error message returned because the specified device does not exist.