Device tags

更新时间:
复制 MD 格式

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:

ParameterTypeDescription
idStringThe 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.
versionStringThe 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.

  • 1: The cloud returns a response.

  • 0: The cloud does not 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.

paramsObject

The request parameters. It contains the tag key attrKey and tag value attrValue.

The params element can contain a maximum of 200 items.

methodStringThe request method. The value must be thing.deviceinfo.update.
attrKeyStringThe 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.
attrValueStringThe 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.
codeIntegerThe result code. A value of 200 indicates success.

Error codes:

Error codeMessageDescription
460request parameter errorThe request parameters are invalid.
6100device not foundThe device does not exist.

Query tag information

Important
  • 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
Alink request data format:
{
    "id": "123",
    "version": "1.0",
    "params":{ 
        "attrKeys":["attrKey1", "attrKey2", "attrKey3"]
    },
    "method": "thing.deviceinfo.get"
}
Alink response data format:
{
    "id": "123",
    "code": 200,
    "data": [
        {
            "attrKey1":"v1"
        },
        {
            "attrKey2":"v2"
        },
        {
            "attrKey3":"v3"
        }
    ]
}
Parameter description:
ParameterTypeDescription
idStringThe 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.
versionStringThe protocol version. The value must be 1.0.
paramsObjectThe request parameters. It contains a list of tag keys to query, which is attrKeys.
attrKeysJSONArrayA list of tag keys to query.
Note
  • If a tag key is invalid, for example, a duplicate tag key exists, an error is returned.
  • If a tag key does not exist, an empty response is returned.
For more information about how to configure key-value pairs for device tags, see Edit device tags.
methodStringThe request method. The value must be thing.deviceinfo.get.
dataJSONArrayThe list of returned tags. It contains the queried tag keys and tag values.
codeIntegerThe result code. A value of 200 indicates success.
Error codes:
Error codeMessageDescription
460request parameter errorThe 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.

429too many requestsThe 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:

ParameterTypeDescription
idStringThe 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.
versionStringThe 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.

  • 1: The cloud returns a response.

  • 0: The cloud does not 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.

paramsObjectThe request parameters. It contains the attrKey parameter of the tag to delete.
methodStringThe request method. The value must be thing.deviceinfo.delete.
attrKeyStringThe key of the tag to delete.
codeIntegerThe result code. A value of 200 indicates success.

Error codes:

Error codeMessageDescription
460request parameter errorThe request parameters are invalid.
6100device not foundThe device does not exist.