View and export a TSL model

更新时间:
复制 MD 格式

After the features are defined, the platform automatically generates a Thing Specification Language (TSL) model in JSON format. The model is based on the Standard function plan and any custom features.

Prerequisites

The Standard function plan and custom features are configured.

Background information

A Thing Model describes what a device is and what it can do, including its properties, services, and events. Alibaba Cloud IoT uses TSL to define Thing Models. Introduction to Thing Models

  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 locally.

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",
        "deviceName": "The device name"
    },
    "properties": [
        {
            "identifier": "The unique identifier of the property (unique within the product)",
            "name": "The property name",
            "accessMode": "The read/write type of the property: read-only (r), write-only (w), or read/write (rw)",
            "required": "Specifies 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 six 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 event name",
            "identifier": "The unique identifier of the event",
            "desc": "The event description",
            "type": "The event type (info, alert, or error)",
            "required": "Specifies whether the event is required",
            "outputData": [
                {
                    "identifier": "The unique identifier of the parameter",
                    "name": "The parameter name",
                    "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 six 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 service name",
            "identifier": "The unique identifier of the service",
            "desc": "The service description",
            "required": "Specifies 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 six 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 six 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": "Get properties",
            "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"
                                    }
                                }
                            }
                        ]
                    }
                }
            ]
        }
    ]
}