This topic answers frequently asked questions (FAQs) about using TSL models for device communication and provides solutions.
Add TSL model features
A TSL model's properties, events, and services must be added and configured in the product that contains the device. You can define a TSL model in the following ways:
-
Call the CreateThingModel API to add TSL model features to a specified product.
-
Add TSL model features in the IoT Platform console. For more information, see Add a single TSL model and Add TSL models in batches.
TSL verification failure during batch import
Symptoms
When you import a TSL model for a product in the IoT Platform console, one of two verification failures may occur in the Import TSL Model dialog box: an immediate error message, The file content is not in a valid JSON format, or a verification exception with a Download and View link for retrieving detailed error information.
Solutions
The following solutions correspond to the two types of verification failures:
-
Check the TSL model file, fix any JSON formatting errors, and then re-upload the file.
-
Click Download and View to obtain the errors.txt file. Use the file to identify and resolve the problem.
For more information about the errors.txt file, see the following example.
Sample TSL model file:
{ "schema":"https://iotx-tsl.oss-ap-southeast-1.aliyuncs.com/schema.json", "profile":{ "productKey":"a1Jk***" }, "services":[], "properties": 1, "events": [], "functionBlockId": "modulemtest", "functionBlockName": "Custom Module 1" }Downloaded 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": "module-test", "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 to the element that caused the verification error. In this example, two errors are found:
// The properties parameter is incorrectly configured. It is not an array. "path": [ "properties" ] // The value of functionBlockId contains a hyphen, which is invalid. "path": [ "functionBlockId" ]property
The specific object under the path that violates the rule.
For example, the property for
"path": ["functionBlockId" ]isinstance.functionBlockId.message
The specific error message.
For example, for
"path": ["functionBlockId" ], the error message for the property isdoes not match pattern \"^[_a-zA-Z0-9]{1,30}$\".schema
The name and content of the verification rule.
For example, for
"path": ["functionBlockId" ], the rules aretypeandpattern.For more information about rule definitions, see JSON Schema.
instance
The specific object being verified.
For example, for
"path": ["functionBlockId" ], the content of"functionBlockId": "module-test"in the TSL model file is verified.name
The name of the rule that failed the verification.
For example, for
"path": ["functionBlockId" ], the objectmodule-testdoes not comply with thepatternrule.argument
The definition of the rule that was violated.
For example, for
"path": ["functionBlockId" ], the unmetpatternrule is defined as^[_a-zA-Z0-9]{1,30}$.stack
A complete error message that combines the property and message fields.
For more information, see jsonschema documentation.
Differences in data reporting methods
Functional differences
|
Feature |
Difference |
|
Property reporting |
Reports a snapshot of device property data. The timestamp is optional:
|
|
Historical data reporting |
Reports values of different properties at the same point in time. This feature is time-based. A timestamp is required. A single data report can include data for multiple time points. |
|
Batch property reporting |
Reports values of the same property at different points in time. This feature is property-based. A timestamp is required. A single data report can include data for multiple properties at multiple time points. |
After property data, historical data, or batch property data is reported to IoT Platform, the platform generates historical data records based on the timestamps.
Differences in communication topics and data formats
The topic and data format differ for each method. For more information, see Device reports properties, Report historical TSL model data, and Device reports properties in batches.
Example
This example uses a device that reports temperature data.
-
Property reporting:
-
The device reports snapshot data with timestamps sequentially from left to right, as shown in the following table.
13:00
14:00
15:00
15:10
60
70
80
90
-
Then, the device reports another snapshot value of 100. The data is updated differently based on whether a timestamp is included:
-
Without a timestamp: The time defaults to the current time (for example, 15:30). In this case, the snapshot value displayed in the IoT Platform console is 100 at 15:30, and the latest entry in the historical data list is also 100 at 15:30.
-
With a timestamp: If the timestamp is 15:00, the data for 15:00 is updated to 100. The snapshot value displayed in the IoT Platform console becomes 100 at 15:00, but the latest entry in the historical data list remains 90 at 15:10.
-
-
-
Historical data reporting:
-
The device reports the following historical data at the same time.
13:00
14:00
15:00
15:10
60
70
80
90
-
Then, the device reports the following historical data at the same time.
13:10
14:10
100
200
In this case, the snapshot value displayed in the IoT Platform console is either 100 at 13:10 or 200 at 14:10, depending on which value was last written to the database. The latest entry in the historical data list remains 90 at 15:10.
-
TSL data not updated with custom topic
You must report device TSL model data using a TSL model communication topic. For more information, see Topic categories and communication.
Retrieve TSL model data
You can retrieve device TSL model data in the following ways:
-
Server-side subscription: Use IoT Platform's server-side subscription feature to subscribe to Device Upstream Notification messages. IoT Platform then forwards these messages from all devices in the product to your server based on your subscription settings. The following two methods for server-side subscription are supported:
-
AMQP server-side subscription: Use an AMQP SDK to receive device messages forwarded by IoT Platform.
-
Message Service (MNS) server-side subscription: Use the Simple Message Queue (formerly MNS) SDK to receive device messages that IoT Platform forwards to Simple Message Queue (formerly MNS).
-
-
Data Forwarding: Use the Data Forwarding feature of the rules engine to create rules that forward specified device data to other cloud services, such as Simple Message Queue (formerly MNS), ApsaraDB for RDS, Tablestore, Function Compute, Time Series Database (TSDB), Lindorm, DataHub, and Message Queue for Apache RocketMQ. For more information, see Data Forwarding (Legacy) and Data Forwarding (New).
-
Cloud APIs:
API
Description
Queries all property snapshots of a specified device.
Queries the original property snapshots reported by a specified device. This includes all properties, regardless of whether they passed TSL model verification.
Queries the original property records reported by a specified device. This includes all properties, regardless of whether they passed TSL model verification.
Queries the original event records reported by a specified device. This includes all events, regardless of whether they passed TSL model verification.
Queries the original service call records from a specified device. This includes all services, regardless of whether they passed TSL model verification.
Queries the desired property values of a specified device.
Queries the data of a single property for a specified device within a specified time range.
Queries the data of multiple properties for a specified device within a specified time range.
Queries the event records of a specified device.
Queries the service call records of a specified device.
TSL model data not in console
When a device reports TSL model data, IoT Platform verifies the data based on the defined TSL model and the configured data validation method. Data that fails verification or has validation skipped is not displayed on the TSL Model Data tab of the Device Details page for the device in the IoT Platform console. For more information, see Validate TSL model data.
You must set the data validation method when you create a product. For more information, see Create a product.
TSL data status not updated after commands
To troubleshoot the issue, investigate the following aspects:
-
Device side: Ensure that the device is properly connected to IoT Platform. For information about how to connect a device, see Download device SDKs.
ImportantA successful command from IoT Platform only confirms that the 'set' request was sent from the cloud; it does not guarantee device execution. For the property to be considered successfully set, the device must apply the new value and then report that value back to the platform.
You can use the device emulator or the MQTT.fx tool to simulate an online device and then use the online debugging feature to debug the device's communication capabilities. For more information, see:
-
IoT Platform cloud side:
-
Ensure that the property for which you want to set a value or a desired value has read/write access.
-
Ensure that TSL model messages are parsed correctly.
Data is displayed in the TSL model's running state only if TSL model messages are parsed correctly. For more information, see TSL models and Parse TSL model messages.
Log on to the IoT Platform console. In the instance, go to the Maintenance > Device Log > Cloud run log page to view logs and check whether the device successfully received the message. For more information, see Cloud run log.
-
Temperature data not in console
TSL model data cannot be displayed if the TSL model property is not defined or the format of the reported data is incorrect.
Follow these steps to ensure the data is displayed correctly:
-
Define a TSL model property named Temperature for the product that contains the device. For more information, see Add TSL model features.
-
The device must report property data using the correct TSL model communication topic and data format. For more information about device-side development, see Device connection.
-
If you selected ICA Standard Data Format (Alink JSON) as the data format when you created the product, the device must use the topic
/sys/${productKey}/${deviceName}/thing/event/property/postand report data in the following format:{ "id": "123", "version": "1.0", "sys":{ "ack":0 }, "params": { "temperature": { "value": 35, "time": 1524448722000 } }, "method": "thing.event.property.post" }For more information about the fields, see Device reports properties.
-
If you selected Passthrough/Custom as the data format when you created the product, you must configure a script to parse TSL model messages.
The device must use the topic
/sys/${productKey}/${deviceName}/thing/model/up_rawto transmit data in hexadecimal format. For more information, see Device reports properties and Parse TSL model messages.
-
Quickly import TSL model features
Yes. IoT Platform provides the following methods to add TSL model features in batches:
-
Add TSL models in batches: In the IoT Platform console, you can copy TSL model features from another product in batches or import a TSL file.
-
CreateThingModel: Use a server-side SDK to call this cloud API and add TSL model features using the ThingModelJson parameter. For more information about the ThingModelJson data format, see ThingModelJson data format.