What is a Thing Specification Language model

更新时间:
复制 MD 格式

A Thing Specification Language (TSL) model is a data model that you define for a product in IoT Platform. It describes the features of the product. This topic describes the concepts and limits of TSL models.

Features

A TSL model is a digital representation in the cloud of a physical entity, such as a sensor, an in-vehicle device, a building, or a factory. It describes what the entity is, what it can do, and what information it can provide from three dimensions: properties, services, and events. By defining these three dimensions for a TSL model, you complete the feature definition for a product.

Feature type

Description

Property

Describes the real-time information and status of a device.

Examples include the current environmental temperature read by an environmental monitoring device, the on/off status of a smart light, and the fan speed of an electric fan.

Properties can be read/write or read-only. You can read and set the values of read/write properties. You can only read the values of read-only properties.

Service

An instruction or method of a device that can be called externally. You can set input and response parameters for a service invocation. Input parameters are used for service execution. Response parameters are the results of the service execution.

Compared with properties, services can use a single instruction to implement more complex business logic, such as executing a specific task.

Services can be invoked in sync or asynchronous mode.

Event

Information that a device actively reports to the cloud during runtime. Events usually include information, alerts, and faults that need to be perceived and processed externally. An event can contain multiple output parameters.

Examples include a notification after a task is complete, the temperature and time when a device fails, and the operating status when a device alert occurs.

Events can be subscribed to and pushed.

In IoT Platform, you can define multiple feature groups (properties, services, and events) for a product. A collection of defined features is called a TSL model module. TSL model modules are independent of each other.

The TSL model module feature simplifies complex device modeling in industrial scenarios. This makes it easier to develop devices that have different features but belong to the same product.

For example, an electric fan heater has the following properties: Power Switch, Gear (High, Medium, Low), and Indoor Temperature. You can add the first two properties to one module and all three properties to another module. Then, you can develop devices with different features based on these modules. This allows different devices under the same product to have different features.

IoT Platform provides a default module. You can add custom modules as needed. The total number of default and custom modules for each product cannot exceed 200.

Important

Product features that were defined before January 1, 2021, are automatically placed in the default TSL model module.

Usage notes

IoT Platform provides Thing Specification Language (TSL) to describe the modules and features of a thing model.

A TSL model module is not required to include properties, services, and events. You can configure them based on your requirements.

A TSL model file is in JSON format. In the IoT Platform console, you can go to the Product Details page, click the Feature Definition tab, and then click TSL Model to view or export the TSL in JSON format. For more information about the fields, see TSL model field description.

IoT Platform supports adding TSL models individually or in batches. For batch imports, you can import a custom TSL model file. For more information about the requirements, see the Limits section below.

Limits

For information about the limits on TSL model feature definitions, see TSL model feature definitions for products and devices. The following table describes the limits for importing TSL model files in batches.

Method

Limits

Single TSL model file

The file must have a .json extension. The file content must be in valid JSON format. The file size cannot exceed 512 KB. The number of valid characters in the file cannot exceed 256 KB (256 × 1024 characters).

Valid characters are all characters in the JSON content except for line breaks and alignment characters.

Multiple TSL model files

  • The files must be compressed into a .zip file. The file size cannot exceed 2.5 MB and must be extractable. After extraction, each file must comply with the specifications for a single TSL file.

  • The compressed package must contain at least one valid TSL model file. It can contain a maximum of one default module TSL model file and nine custom module TSL model files.

    Important

    The values of functionBlockName and functionBlockId cannot be the same in different custom TSL model files.

References