All Products
Search
Document Center

IoT Platform:FAQ about TSL models

Last Updated:May 04, 2023

This topic provides answers to some frequently asked questions (FAQ) about how to use Thing Specification Language (TSL) models to enable communication between devices and IoT Platform.

What do I do if verification fails when I import a TSL model file?

Issue

Verification errors occur when you import a TSL model file, as shown in the following figure. Issue

Solution

To fix the verification errors, use the following solutions:

  • Solution 1: Check the format of the TSL model file and make sure that the file is in the JSON format.

  • Solution 2: Click Download and View to obtain an errors.txt file. Troubleshoot and resolve the issues based on the errors.txt file.

    For more information about the errors.txt file, see the following sample file.

    Sample TSL model file:

    {
        "schema":"https://iotx-tsl.oss-ap-southeast-1.aliyuncs.com/schema.json",
        "profile":{
            "productKey":"a1Jk***"
        },
        "services":[],
        "properties": 1,
        "events": [],
        "functionBlockId": "**mtest",
        "functionBlockName": "Custom module 1"
    }

    Sample errors.txt file:

    [
      {
        "path": [
          "properties"
        ],
        "property": "instance.properties",
        "message": "is not of a type(s) array",
        "schema": {
          "type": "array",
          "items": {
            "$ref": "#/definitions/propertyDefinition"
          }
        },
        "instance": 1,
        "name": "type",
        "argument": [
          "array"
        ],
        "stack": "instance.properties is not of a type(s) array"
      },
      {
        "path": [
          "functionBlockId"
        ],
        "property": "instance.functionBlockId",
        "message": "does not match pattern \"^[_a-zA-Z0-9]{1,30}$\"",
        "schema": {
          "type": "string",
          "pattern": "^[_a-zA-Z0-9]{1,30}$"
        },
        "instance": "**mtest",
        "name": "pattern",
        "argument": "^[_a-zA-Z0-9]{1,30}$",
        "stack": "instance.functionBlockId does not match pattern \"^[_a-zA-Z0-9]{1,30}$\""
      }
    ]

    Parameter

    Description

    path

    The path of the error. In this example, the following errors are detected:

    // The value of the properties parameter is not an array.
    "path": [
          "properties"
        ]
    // The value of the functionBlockId parameter contains invalid characters.
    "path": [
          "functionBlockId"
        ]

    property

    The invalid property in "path".

    For example, in "path": ["functionBlockId" ], the value of the instance.functionBlockId property is invalid.

    message

    The error message.

    For example, in "path": ["functionBlockId" ], the error message does not match pattern \"^[_a-zA-Z0-9]{1,30}$\" is returned for the instance.functionBlockId property.

    schema

    The rule that is used to verify the TSL model file.

    For example, in "path": ["functionBlockId" ], the type and pattern rules are used.

    For more information about the rules, see schema.

    instance

    The object that is verified.

    For example, in "path": ["functionBlockId" ], the setting of "functionBlockId": "**mtest" is verified.

    name

    The name of the rule that is not matched in the verification.

    For example, in "path": ["functionBlockId" ], the value of **mtest does not match the pattern rule.

    argument

    The content of the rule that is not matched in the verification.

    For example, in "path": ["functionBlockId" ], the content of the pattern rule is ^[_a-zA-Z0-9]{1,30}$.

    stack

    The concatenated values of the property and message parameters.

For more information, see jsonschema.

What are the differences among submitting property data, submitting historical data, and submitting multiple values of properties at the same time?

The following table describes the differences.

Operation

Description

Submit property data

A device submits a snapshot of its property data to IoT Platform. The timestamp is optional in the submitted data.

  • If the submitted data contains a timestamp, IoT Platform saves the timestamp to record the time when the property data is submitted.

    A device can submit property data with only one timestamp at a time.

  • If the submitted property data does not contain a timestamp, IoT Platform generates a timestamp to record the time when the data is submitted.

Submit historical property data

A device submits the values of multiple properties to IoT Platform. The values are recorded at the same point in time. Timestamps must be specified in the submitted data.

A device can submit values of multiple properties with different timestamps at a time.

Submit multiple values of properties at a time

A device submits multiple values of a property to IoT Platform. The values are recorded at different points in time. Timestamps must be specified in the submitted data.

A device can submit values of multiple properties with different timestamps at a time.

After devices submit property data, historical data, or multiple values of properties, IoT Platform generates data records based on the timestamps.

Differences between communication topics and data formats

Topics and data formats vary based on the type of data that is submitted to IoT Platform. For more information, see Devices submit property data to IoT Platform, Devices submit historical TSL data to IoT Platform, and Devices submit multiple properties and events to IoT Platform at a time.

Examples

In this example, the data of the temperature property is submitted by a device to IoT Platform.

  • The device submits snapshot values of the temperature property.

    1. The device submits the following values of the temperature property with timestamps from left to right in sequence.

      13:00

      14:00

      15:00

      15:10

      60

      70

      80

      90

    2. The device submits the snapshot value 100 of the temperature property. The following data is displayed based on the method that the device uses to submit data.

      • If no timestamps exist, IoT Platform generates a timestamp based on the time when the data is submitted. In this example, 15:30:00 is used. In this case, 100 is displayed in the IoT Platform console as the value of the temperature property. The value 100 is also the most recent value of the temperature property in the data records.

      • If a timestamp (for example, 15:00:00) is specified, 100 replaces 80 as the value of the temperature property at 15:00:00. In this case,100 is displayed in the IoT Platform console as the value of the temperature property. The most recent value of the temperature property in the data records is 90 at 15:10:00.

  • The device submits historical values of the temperature property.

    1. The device submits the following historical values of the temperature property at the same time.

      13:00

      14:00

      15:00

      15:10

      60

      70

      80

      90

    2. The device submits the following historical values of the temperature property at the same time.

      13:10

      14:10

      100

      200

      The most recent temperature value that is written to the database is displayed in the IoT Platform console as the value of the temperature property. In this example, 100 at 13:10:00 is displayed or 200 at 14:10:00 is displayed. The most recent value of the temperature property in the data records is 90 at 15:10:00.

Why is the TSL data of a device not updated in the IoT Platform console after the device submits the TSL data by using a custom topic?

Because a device must submit TSL data by using a TSL communication topic instead of using a custom topic. For more information, see Topics.

How do I obtain TSL data that is submitted by devices?

To obtain TSL data, use one of the following methods:

  • Server-side subscription: You can use the server-side subscription feature of IoT Platform to subscribe to messages of the Device Upstream Notification type. Then, IoT Platform forwards messages of the specified types from all devices in a product to a server based on your subscription settings. To configure a server-side subscription, use one of the following methods:

  • Data forwarding: You can configure data forwarding rules by using the data forwarding feature of the rules engine to forward device data to multiple Alibaba Cloud services. The services include Message Service (MNS), ApsaraDB RDS, Tablestore (OTS), Function Compute, Lindorm, and Message Queue for Apache RocketMQ. For more information, see Data forwarding (old version) and Data forwarding (new version).

  • IoT Platform API operations

    API

    Description

    QueryDevicePropertyStatus

    Queries all property snapshots of a device.

    QueryDeviceOriginalPropertyStatus

    Queries the original property snapshots that are submitted by a specified device. These snapshots include properties that are verified and not verified by a specified TSL model.

    QueryDeviceOriginalPropertyData

    Queries the original property records that are submitted by a specified device. These records include properties that are verified and not verified by a specified TSL model.

    QueryDeviceOriginalEventData

    Queries the event records that are submitted by a specified device. These records include events that are verified and not verified by a specified TSL model.

    QueryDeviceOriginalServiceData

    Queries the original service records that are submitted by a specified device. These records include services that are verified and not verified by a specified TSL model.

    QueryDeviceDesiredProperty

    Queries the desired property values of a device.

    QueryDevicePropertyData

    Queries the data of a property in a device within a specified period of time.

    QueryDevicePropertiesData

    Queries the data of multiple properties in a device within a specified period of time.

    QueryDeviceEventData

    Queries the original event records of a device.

    QueryDeviceServiceData

    Queries the service call records of a device.

Why does the IoT Platform console not display the TSL data that is submitted by a device?

If the submitted TSL data does not require verification or fails to be verified, the TSL data is not displayed in the IoT Platform console. After a device submits TSL data to IoT Platform, IoT Platform verifies the data based on the specified verification type and the TSL definition. To view the TSL data of a device, perform the following steps: Log on to the IoT Platform console, find the device whose TSL data you want to view, and then click View in the Actions column. On the device details page, the TSL Data tab displays the TSL data. For more information, see Verify TSL data.

When you create a product, you must specify a verification type. For more information, see Create a product.

What do I do if the TSL data is not updated after IoT Platform successfully sends TSL property configuration requests and desired property values to devices?

To troubleshoot the issue, you can perform the following operations:

  • Device: Make sure that the device is connected to the IoT Platform. For more information about how to connect a device, see Download device SDKs.

    Important

    When IoT Platform successfully sends a request of configuring device properties to a device, the request is received but the device may not execute the request. After the device SDK responds to the property configuration request, the device must submit the latest property value to prove that the property value is changed.

    You can also use the device simulator or MQTT.fx to simulate a device and connect the simulated device to IoT platform, and then debug messaging of the device online. For more information, see the following topics:

  • IoT Platform:

    • Make sure that you have the read and write permissions on the property that you want to manage to perform the Set and Set expectations operations.

    • Make sure that the messages that contain TSL data can be parsed properly.

      This way, the latest TSL data can be displayed on the TSL Data tab in the IoT Platform console. For more information, see What is a TSL model? and Submit a script to parse TSL data.

    You can perform the following operations to check whether the device received messages: Log on to the IoT Platform console, find the instance that you want to manage, and go to the Instance Details page. Choose Maintenance > Device Log > Cloud run log and view logs. For more information, see IoT Platform logs.