You can report device information, such as the manufacturer and model number, as device tags. You can also query and delete the tags that are associated with a device. This topic describes the topics and data formats used for reporting, querying, and deleting device tags.
Report tag information
Uplink operation.
- Request topic:
/sys/${productKey}/${deviceName}/thing/deviceinfo/update - Response topic:
/sys/${productKey}/${deviceName}/thing/deviceinfo/update_reply
Alink request data format:
{
"id": "123",
"version": "1.0",
"sys":{
"ack":0
},
"params":[
{
"attrKey": "Temperature",
"attrValue": "36.8"
}
],
"method": "thing.deviceinfo.update"
}Alink response data format:
{
"id": "123",
"code": 200,
"data": {}
}Parameter description:
| Parameter | Type | Description |
| id | String | The message ID. It must be a string that contains a number. The value must be unique for the device. The value range is 0 to 4294967295. |
| version | String | The protocol version. The value must be 1.0. |
sys | Object | Parameters for extended features. It contains fields for different features. Note If you use a device-side software development kit (SDK) for development and do not set extended features, this parameter is not included. The related features use default configurations. |
ack | Integer | An extended feature field under sys. It specifies whether to return a response.
Important For information about how to configure this feature, see Thing Specification Language model usage examples. If this feature is not configured, this parameter is not included. The cloud returns a response by default. |
| params | Object | The request parameters. It contains the tag key attrKey and tag value attrValue. The params element can contain a maximum of 200 items. |
| method | String | The request method. The value must be thing.deviceinfo.update. |
| attrKey | String | The tag key. It can contain letters, digits, underscores (_), hyphens (-), number signs (#), at signs (@), percent signs (%), ampersands (&), asterisks (*), and periods (.). The key can be up to 30 characters long. |
| attrValue | String | The tag value. It can contain Chinese characters, Japanese characters, letters, digits, underscores (_), hyphens (-), number signs (#), at signs (@), percent signs (%), ampersands (&), colons (:), and periods (.). The value can be up to 128 characters long. A Chinese or Japanese character is counted as two characters. |
| code | Integer | The result code. A value of 200 indicates success. |
Error codes:
| Error code | Message | Description |
| 460 | request parameter error | The request parameters are invalid. |
| 6100 | device not found | The device does not exist. |
Query tag information
- You can query a maximum of 10 tags at a time.
- You can query only custom tags. You cannot query internal system tags of the IoT Platform.
- You must specify the tag keys that you want to query. If you do not specify any tag keys, no tag data is returned.
Uplink operation.
- Request topic:
/sys/${productKey}/${deviceName}/thing/deviceinfo/get - Response topic:
/sys/${productKey}/${deviceName}/thing/deviceinfo/get_reply
{
"id": "123",
"version": "1.0",
"params":{
"attrKeys":["attrKey1", "attrKey2", "attrKey3"]
},
"method": "thing.deviceinfo.get"
}{
"id": "123",
"code": 200,
"data": [
{
"attrKey1":"v1"
},
{
"attrKey2":"v2"
},
{
"attrKey3":"v3"
}
]
}| Parameter | Type | Description |
| id | String | The message ID. It must be a string that contains a number. The value must be unique for the device. The value range is 0 to 4294967295. |
| version | String | The protocol version. The value must be 1.0. |
| params | Object | The request parameters. It contains a list of tag keys to query, which is attrKeys. |
| attrKeys | JSONArray | A list of tag keys to query. Note
|
| method | String | The request method. The value must be thing.deviceinfo.get. |
| data | JSONArray | The list of returned tags. It contains the queried tag keys and tag values. |
| code | Integer | The result code. A value of 200 indicates success. |
| Error code | Message | Description |
| 460 | request parameter error | The request parameters are invalid. For example, the attrKeys parameter is not a JSONArray, a tag key is empty or duplicated, or the number of tags to query exceeds the limit of 10. |
| 429 | too many requests | The number of requests per second is too high and triggers throttling. The current queries per second (QPS) limit for a single Alibaba Cloud account is 50. Note Resource Access Management (RAM) users share the quota of the Alibaba Cloud account. |
Delete tag information
Uplink operation.
- Request topic:
/sys/${productKey}/${deviceName}/thing/deviceinfo/delete - Response topic:
/sys/${productKey}/${deviceName}/thing/deviceinfo/delete_reply
Alink request data format:
{
"id": "123",
"version": "1.0",
"sys":{
"ack":0
},
"params": [
{
"attrKey": "Temperature"
}
],
"method": "thing.deviceinfo.delete"
}Alink response data format:
{
"id": "123",
"code": 200,
"data": {}
}Parameter description:
| Parameter | Type | Description |
| id | String | The message ID. It must be a string that contains a number. The value must be unique for the device. The value range is 0 to 4294967295. |
| version | String | The protocol version. The value must be 1.0. |
sys | Object | Parameters for extended features. It contains fields for different features. Note If you use a device-side software development kit (SDK) for development and do not set extended features, this parameter is not included. The related features use default configurations. |
ack | Integer | An extended feature field under sys. It specifies whether to return a response.
Important For information about how to configure this feature, see Thing Specification Language model usage examples. If this feature is not configured, this parameter is not included. The cloud returns a response by default. |
| params | Object | The request parameters. It contains the attrKey parameter of the tag to delete. |
| method | String | The request method. The value must be thing.deviceinfo.delete. |
| attrKey | String | The key of the tag to delete. |
| code | Integer | The result code. A value of 200 indicates success. |
Error codes:
| Error code | Message | Description |
| 460 | request parameter error | The request parameters are invalid. |
| 6100 | device not found | The device does not exist. |