TSL Model & Profile Template Introduction

This topic introduces what is a TSL model and Profile template, along with their format and structure.

TSL model

Introduction
A Thing Specification Language (TSL) model is a standardized data model that defines a device's characteristics, features, and behaviors within Milesight Development Platform. A TSL model provides a structured way to represent device information, including its identity, capabilities, and data provision.
Format
Format of TSL model files: JSON.
Structure
A TSL model for Milesight Development Platform includes version, properties, events, and services as the following example shows.
{
    "data": {
        "version": "v1.0",    // Version of the TSL model.
        "properties": [    // Status or information of this device.
            {
                "id": "",    
                "name": "",           
                "accessMode": "",     // The access mode of the property.
                "hidden": true,    // Whether this property is displayed.
                "dataSpec": {}    // Detailed info (data definition) of this property.
            }
        ],
        "events": [    // Data that a device reports to Milesight Developement Platform.
            {
                "id": "",                
                "name": "",
                "type": "",
                "hidden": false,
                "outputs": []    // The reported data when this event occurs.
            }
        ],
        "services": [    // Available services that can be invoked on this device.
            {
                "id": "",
                "name": "",
                "callType": "",    // The type of this service invocation:
                "hidden": false,
                "inputs": [],    // The downlink data when this service is invoked.
                "outputs": []    // The reported data when this service is invoked.
            }
        ]
    }
}
Description
Item Description
version Version of this TSL model.
properties Properties are characteristics or attributes of a device that can be read or written, depending on the access mode, properties are classified in the followings:
  • Read-only: Static data or values that can NOT be changed, which describes the device's status or information.

    For example, the SN (Serial Number) and firmware version of a device.

  • Write-only: Configurable parameters, which represent the device's settings that can be configured.

    For example, the data reporting interval of a sensor.

    Note: You can modify the values of Write-only properties through API to update the device's settings.
  • Read/write: Parameters that not only describe device information but also can be modified.

    For example, the on/off status of a smart socket.

    Note: You can modify the values of Read/write properties through API to update the device's settings.
events Events refer to the data that a device report to Milesight Development Platform when specific event occurs.

For example, a People Counting Sensor is set to report upon line-crossing, when the sensor detects a person crossing the line, it will report the related data to Milesight Development Platform.

services Services refer to the actions that can be performed on the device. It represents a method or operation that can be invoked to interact with the device.
For example, reboot the device, and query the historical data of a device.
Note: You can invoke the service via API.

Profile template

Introduction
A Profile template outlines all the settings for an Internet-accessible device that can be configured on Milesight Development Platform. You can use the default Profile templates to apply the standard configuration for devices, or create a custom Profile template to update the settings as needed, then apply them to your devices.
Format
Format of Profile templates: JSON.
Structure
A Profile template is structured with a version and a list of key-value pairs, as the following example shows.
{
    "version": "v1.0",    // Version of the Profile template.
    "values": [    
        {
            "key": "********",    // The configurable setting.
            "value": 1     
        },
        {
            "key": "*********",
            "value": 0
        },
        ..........
    ]
}