View and export a TSL model

更新时间:
复制 MD 格式

After you define the features for a product, the platform automatically generates a Thing Specification Language (TSL) model in JSON format based on the standard and custom functions.

Prerequisites

You have configured the standard and custom functions.

Background information

A TSL model describes a device and its capabilities, including properties, services, and events. Alibaba Cloud IoT uses TSL to define these models. For more information, see Introduction to TSL models.

Procedure

  1. Go to the Product > Feature Definition page.
  2. On the Feature Definition tab, click View TSL Model.
  3. Click Export Model File to save the JSON file to your computer.

Examples

TSL field descriptions
{
    "schema": "The schema of the TSL description for the thing",
    "link": "The system-level URI on the cloud, used to call services or subscribe to events",
    "profile": {
        "productKey": "The ProductKey of the product",
        "deviceName": "The name of the device"
    },
    "properties": [
        {
            "identifier": "The unique identifier of the property (unique within the product)",
            "name": "The name of the property",
            "accessMode": "The read/write type of the property: read-only (r), write-only (w), or read/write (rw)",
            "required": "Indicates whether the property is required",
            "dataType": {
                "type": "The property type: int (native), float (native), double (native), text (native), date (String in UTC milliseconds), bool (int, 0 or 1), enum (int), or struct (can contain the preceding 6 types)",
                "specs": {
                    "min": "The minimum value of the property (specific to int, float, and double types)",
                    "max": "The maximum value of the property (specific to int, float, and double types)",
                    "unit": "The unit of the property",
                    "unitName": "The name of the unit"
                }
            }
        }
    ],
    "events": [
        {
            "name": "The name of the event",
            "identifier": "The unique identifier of the event",
            "desc": "The description of the event",
            "type": "The event type (info, alert, or error)",
            "required": "Indicates whether the event is required",
            "outputData": [
                {
                    "identifier": "The unique identifier of the parameter",
                    "name": "The name of the parameter",
                    "dataType": {
                        "type": "The parameter type: int (native), float (native), double (native), text (native), date (String in UTC milliseconds), bool (int, 0 or 1), enum (int), or struct (can contain the preceding 6 types)",
                        "specs": {
                            "min": "The minimum value of the parameter (specific to int, float, and double types)",
                            "max": "The maximum value of the parameter (specific to int, float, and double types)",
                            "unit": "The unit of the parameter",
                            "unitName": "The name of the unit"
                        }
                    }
                }
            ],
            "method": "The method name corresponding to the event (generated based on the identifier)"
        }
    ],
    "services": [
        {
            "name": "The name of the service",
            "identifier": "The unique identifier of the service",
            "desc": "The description of the service",
            "required": "Indicates whether the service is required",
            "inputData": [
                {
                    "identifier": "The unique identifier of the input parameter",
                    "name": "The name of the input parameter",
                    "dataType": {
                        "type": "The input parameter type: int (native), float (native), double (native), text (native), date (String in UTC milliseconds), bool (int, 0 or 1), enum (int), or struct (can contain the preceding 6 types)",
                        "specs": {
                            "min": "The minimum value of the input parameter (specific to int, float, and double types)",
                            "max": "The maximum value of the input parameter (specific to int, float, and double types)",
                            "unit": "The unit of the input parameter",
                            "unitName": "The name of the unit"
                        }
                    }
                }
            ],
            "outputData": [
                {
                    "identifier": "The unique identifier of the response parameter",
                    "name": "The name of the response parameter",
                    "dataType": {
                        "type": "The response parameter type: int (native), float (native), double (native), text (native), date (String in UTC milliseconds), bool (int, 0 or 1), enum (int), or struct (can contain the preceding 6 types)",
                        "specs": {
                            "min": "The minimum value of the response parameter (specific to int, float, and double types)",
                            "max": "The maximum value of the response parameter (specific to int, float, and double types)",
                            "unit": "The unit of the response parameter",
                            "unitName": "The name of the unit"
                        }
                    }
                }
            ],
            "method": "The method name corresponding to the service (generated based on the identifier)"
        }
    ]
}
TSL example
{
    "schema": "http://aliyun/iot/thing/desc/schema",
    "link": "/sys/q408EXte2fy/airCondition/thing/",
    "profile": {
        "productKey": "q408EXte2fy",
        "deviceName": "airCondition"
    },
    "properties": [
        {
            "identifier": "fan_doule_property",
            "name": "Fan double-precision property",
            "accessMode": "r",
            "required": true,
            "dataType": {
                "type": "double",
                "specs": {
                    "min": "0.0",
                    "max": "100.0",
                    "unit": "g/ml",
                    "unitName": "milliliter"
                }
            }
        },
        {
            "identifier": "fan_int_property",
            "name": "Fan integer property",
            "accessMode": "rw",
            "required": true,
            "dataType": {
                "type": "int",
                "specs": {
                    "min": "0",
                    "max": "100",
                    "unit": "g/ml",
                    "unitName": "milliliter"
                }
            }
        },
        {
            "identifier": "batch_enum_attr_id",
            "name": "Fan enumeration property",
            "accessMode": "r",
            "required": true,
            "dataType": {
                "type": "enum",
                "specs": {
                    "0": "one",
                    "1": "two",
                    "2": "three"
                }
            }
        },
        {
            "identifier": "fan_float_property",
            "name": "Fan float property test",
            "accessMode": "r",
            "required": true,
            "dataType": {
                "type": "float",
                "specs": {
                    "min": "0.0",
                    "max": "100.0",
                    "unit": "g/ml",
                    "unitName": "milliliter"
                }
            }
        },
        {
            "identifier": "fan_text_property",
            "name": "Fan text property",
            "accessMode": "r",
            "required": true,
            "dataType": {
                "type": "text",
                "specs": {
                    "length": "64",
                    "unit": "g/ml",
                    "unitName": "milliliter"
                }
            }
        },
        {
            "identifier": "fan_date_property",
            "name": "Fan date property",
            "accessMode": "r",
            "required": true,
            "dataType": {
                "type": "date",
                "specs": {}
            }
        },
        {
            "identifier": "batch_boolean_attr_id",
            "name": "Fan Boolean property",
            "accessMode": "r",
            "required": true,
            "dataType": {
                "type": "bool",
                "specs": {
                    "0": "close",
                    "1": "open"
                }
            }
        },
        {
            "identifier": "fan_struct_property",
            "name": "Fan struct property",
            "accessMode": "r",
            "required": true,
            "dataType": {
                "type": "struct",
                "specs": [
                    {
                        "identifier": "fan_struct_property_float_child",
                        "name": "Fan double-precision property",
                        "dataType": {
                            "type": "double",
                            "specs": {
                                "min": "0.0",
                                "max": "100.0",
                                "unit": "g/ml",
                                "unitName": "milliliter"
                            }
                        }
                    },
                    {
                        "identifier": "fan_struct_property_float_child",
                        "name": "Fan struct float sub-property",
                        "dataType": {
                            "type": "float",
                            "specs": {
                                "min": "0.0",
                                "max": "255.0",
                                "unit": "°",
                                "unitName": "degree"
                            }
                        }
                    },
                    {
                        "identifier": "fan_struct_property_int_child",
                        "name": "Fan struct integer sub-property",
                        "dataType": {
                            "type": "int",
                            "specs": {
                                "min": "0",
                                "max": "255",
                                "unit": "°",
                                "unitName": "degree"
                            }
                        }
                    },
                    {
                        "identifier": "fan_struct_property_text_child",
                        "name": "Fan struct text sub-property",
                        "dataType": {
                            "type": "text",
                            "specs": {
                                "length": "200",
                                "unit": "unit",
                                "unitName": "unit"
                            }
                        }
                    },
                    {
                        "identifier": "fan_struct_property_date_child",
                        "name": "Fan struct date sub-property",
                        "dataType": {
                            "type": "date",
                            "specs": {}
                        }
                    },
                    {
                        "identifier": "fan_struct_property_enum_child",
                        "name": "Fan struct enumeration sub-property",
                        "dataType": {
                            "type": "enum",
                            "specs": {
                                "0": "one",
                                "1": "two",
                                "2": "three"
                            }
                        }
                    },
                    {
                        "identifier": "fan_struct_property_boolean_child",
                        "name": "Fan struct Boolean sub-property",
                        "dataType": {
                            "type": "bool",
                            "specs": {
                                "0": "close",
                                "1": "open"
                            }
                        }
                    }
                ]
            }
        }
    ],
    "events": [
        {
            "name": "alarm",
            "identifier": "alarm",
            "desc": "Alarm",
            "type": "info",
            "required": true,
            "outputData": [
                {
                    "identifier": "errorCode",
                    "name": "Error code",
                    "dataType": {
                        "type": "text",
                        "specs": {
                            "length": "255",
                            "unit": ""
                        }
                    }
                }
            ],
            "method": "thing.event.alarm.post"
        },
        {
            "identifier": "post",
            "name": "post",
            "type": "info",
            "required": true,
            "desc": "Property reporting",
            "method": "thing.event.property.post",
            "outputData": [
                {
                    "identifier": "fan_doule_property",
                    "name": "Fan double-precision property",
                    "dataType": {
                        "type": "double",
                        "specs": {
                            "min": "0.0",
                            "max": "100.0",
                            "unit": "g/ml",
                            "unitName": "milliliter"
                        }
                    }
                },
                {
                    "identifier": "fan_int_property",
                    "name": "Fan integer property",
                    "dataType": {
                        "type": "int",
                        "specs": {
                            "min": "0",
                            "max": "100",
                            "unit": "g/ml",
                            "unitName": "milliliter"
                        }
                    }
                },
                {
                    "identifier": "batch_enum_attr_id",
                    "name": "Fan enumeration property",
                    "dataType": {
                        "type": "enum",
                        "specs": {
                            "0": "one",
                            "1": "two",
                            "2": "three"
                        }
                    }
                },
                {
                    "identifier": "fan_float_property",
                    "name": "Fan float property test",
                    "dataType": {
                        "type": "float",
                        "specs": {
                            "min": "0.0",
                            "max": "100.0",
                            "unit": "g/ml",
                            "unitName": "milliliter"
                        }
                    }
                },
                {
                    "identifier": "fan_text_property",
                    "name": "Fan text property",
                    "dataType": {
                        "type": "text",
                        "specs": {
                            "length": "64",
                            "unit": "g/ml",
                            "unitName": "milliliter"
                        }
                    }
                },
                {
                    "identifier": "fan_date_property",
                    "name": "Fan date property",
                    "dataType": {
                        "type": "date",
                        "specs": {}
                    }
                },
                {
                    "identifier": "batch_boolean_attr_id",
                    "name": "Fan Boolean property",
                    "dataType": {
                        "type": "bool",
                        "specs": {
                            "0": "close",
                            "1": "open"
                        }
                    }
                },
                {
                    "identifier": "fan_struct_property",
                    "name": "Fan struct property",
                    "dataType": {
                        "type": "struct",
                        "specs": [
                            {
                                "identifier": "fan_struct_property_double_child",
                                "name": "Fan double-precision property",
                                "dataType": {
                                    "type": "double",
                                    "specs": {
                                        "min": "0.0",
                                        "max": "100.0",
                                        "unit": "g/ml",
                                        "unitName": "milliliter"
                                    }
                                }
                            },
                            {
                                "identifier": "fan_struct_property_float_child",
                                "name": "Fan struct float sub-property",
                                "dataType": {
                                    "type": "float",
                                    "specs": {
                                        "min": "0.0",
                                        "max": "255.0",
                                        "unit": "°",
                                        "unitName": "degree"
                                    }
                                }
                            },
                            {
                                "identifier": "fan_struct_property_int_child",
                                "name": "Fan struct integer sub-property",
                                "dataType": {
                                    "type": "int",
                                    "specs": {
                                        "min": "0",
                                        "max": "255",
                                        "unit": "°",
                                        "unitName": "degree"
                                    }
                                }
                            },
                            {
                                "identifier": "fan_struct_property_text_child",
                                "name": "Fan struct text sub-property",
                                "dataType": {
                                    "type": "text",
                                    "specs": {
                                        "length": "200",
                                        "unit": "unit",
                                        "unitName": "unit"
                                    }
                                }
                            },
                            {
                                "identifier": "fan_struct_property_date_child",
                                "name": "Fan struct date sub-property",
                                "dataType": {
                                    "type": "date",
                                    "specs": {}
                                }
                            },
                            {
                                "identifier": "fan_struct_property_enum_child",
                                "name": "Fan struct enumeration sub-property",
                                "dataType": {
                                    "type": "enum",
                                    "specs": {
                                        "0": "one",
                                        "1": "two",
                                        "2": "three"
                                    }
                                }
                            },
                            {
                                "identifier": "fan_struct_property_boolean_child",
                                "name": "Fan struct Boolean sub-property",
                                "dataType": {
                                    "type": "bool",
                                    "specs": {
                                        "0": "0",
                                        "1": "1"
                                    }
                                }
                            }
                        ]
                    }
                }
            ]
        }
    ],
    "services": [
        {
            "name": "upgrade",
            "identifier": "upgrade",
            "desc": "Upgrade service",
            "inputData": [
                {
                    "identifier": "model",
                    "name": "Model",
                    "dataType": {
                        "type": "int",
                        "specs": {
                            "min": "1",
                            "max": "100",
                            "unit": "cm"
                        }
                    }
                },
                {
                    "identifier": "mac",
                    "name": "MAC address",
                    "dataType": {
                        "type": "text",
                        "specs": {
                            "length": "255"
                        }
                    }
                }
            ],
            "outputData": [
                {
                    "identifier": "firmVersion",
                    "name": "Firmware version number",
                    "dataType": {
                        "type": "int",
                        "specs": {
                            "min": "1",
                            "max": "100",
                            "unit": ""
                        }
                    }
                }
            ],
            "method": "thing.service.upgrade"
        },
        {
            "identifier": "set",
            "name": "set",
            "required": true,
            "desc": "Property settings",
            "method": "thing.service.property.set",
            "inputData": [
                {
                    "identifier": "fan_int_property",
                    "name": "Fan integer property",
                    "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": "Property retrieval",
            "method": "thing.service.property.get",
            "inputData": [
                "fan_doule_property",
                "fan_int_property",
                "batch_enum_attr_id",
                "fan_float_property",
                "fan_text_property",
                "fan_date_property",
                "batch_boolean_attr_id",
                "fan_struct_property"
            ],
            "outputData": [
                {
                    "identifier": "fan_doule_property",
                    "name": "Fan double-precision property",
                    "dataType": {
                        "type": "double",
                        "specs": {
                            "min": "0.0",
                            "max": "100.0",
                            "unit": "g/ml",
                            "unitName": "milliliter"
                        }
                    }
                },
                {
                    "identifier": "fan_int_property",
                    "name": "Fan integer property",
                    "dataType": {
                        "type": "int",
                        "specs": {
                            "min": "0",
                            "max": "100",
                            "unit": "g/ml",
                            "unitName": "milliliter"
                        }
                    }
                },
                {
                    "identifier": "batch_enum_attr_id",
                    "name": "Fan enumeration property",
                    "dataType": {
                        "type": "enum",
                        "specs": {
                            "0": "one",
                            "1": "two",
                            "2": "three"
                        }
                    }
                },
                {
                    "identifier": "fan_float_property",
                    "name": "Fan float property test",
                    "dataType": {
                        "type": "float",
                        "specs": {
                            "min": "0.0",
                            "max": "100.0",
                            "unit": "g/ml",
                            "unitName": "milliliter"
                        }
                    }
                },
                {
                    "identifier": "fan_text_property",
                    "name": "Fan text property",
                    "dataType": {
                        "type": "text",
                        "specs": {
                            "length": "64",
                            "unit": "g/ml",
                            "unitName": "milliliter"
                        }
                    }
                },
                {
                    "identifier": "fan_date_property",
                    "name": "Fan date property",
                    "dataType": {
                        "type": "date",
                        "specs": {}
                    }
                },
                {
                    "identifier": "batch_boolean_attr_id",
                    "name": "Fan Boolean property",
                    "dataType": {
                        "type": "bool",
                        "specs": {
                            "0": "close",
                            "1": "open"
                        }
                    }
                },
                {
                    "identifier": "fan_struct_property",
                    "name": "Fan struct property",
                    "dataType": {
                        "type": "struct",
                        "specs": [
                            {
                                "identifier": "fan_struct_property_double_child",
                                "name": "Fan double-precision property",
                                "dataType": {
                                    "type": "double",
                                    "specs": {
                                        "min": "0.0",
                                        "max": "100.0",
                                        "unit": "g/ml",
                                        "unitName": "milliliter"
                                    }
                                }
                            },
                            {
                                "identifier": "fan_struct_property_float_child",
                                "name": "Fan struct float sub-property",
                                "dataType": {
                                    "type": "float",
                                    "specs": {
                                        "min": "0.0",
                                        "max": "255.0",
                                        "unit": "°",
                                        "unitName": "degree"
                                    }
                                }
                            },
                            {
                                "identifier": "fan_struct_property_int_child",
                                "name": "Fan struct integer sub-property",
                                "dataType": {
                                    "type": "int",
                                    "specs": {
                                        "min": "0",
                                        "max": "255",
                                        "unit": "°",
                                        "unitName": "degree"
                                    }
                                }
                            },
                            {
                                "identifier": "fan_struct_property_text_child",
                                "name": "Fan struct text sub-property",
                                "dataType": {
                                    "type": "text",
                                    "specs": {
                                        "length": "200",
                                        "unit": "unit",
                                        "unitName": "unit"
                                    }
                                }
                            },
                            {
                                "identifier": "fan_struct_property_date_child",
                                "name": "Fan struct date sub-property",
                                "dataType": {
                                    "type": "date",
                                    "specs": {}
                                }
                            },
                            {
                                "identifier": "fan_struct_property_enum_child",
                                "name": "Fan struct enumeration sub-property",
                                "dataType": {
                                    "type": "enum",
                                    "specs": {
                                        "0": "one",
                                        "1": "two",
                                        "2": "three"
                                    }
                                }
                            },
                            {
                                "identifier": "fan_struct_property_boolean_child",
                                "name": "Fan struct Boolean sub-property",
                                "dataType": {
                                    "type": "bool",
                                    "specs": {
                                        "0": "close",
                                        "1": "open"
                                    }
                                }
                            }
                        ]
                    }
                }
            ]
        }
    ]
}