V2.4 Search Sub-Device¶
搜索网关下的子设备信息。
使用此 API 前,确保已安装 EnOS 2.4 CU1 或更新版本。
如果你在使用 API 批量更新相关设备信息后调用当前 API,建议两次调用间隔 2 秒左右,以免获取到未更新数据。
请求格式¶
POST https://{apigw-address}/connect-service/v2.4/device-topos?action=searchSubDevice
请求参数(URI)¶
名称  | 
位置(Path/Query)  | 
必需/可选  | 
数据类型  | 
描述  | 
|---|---|---|---|---|
orgId  | 
Query  | 
必需  | 
String  | 
设备所属的 OU ID。如何获取 orgId 信息>>  | 
请求参数(Body)¶
名称  | 
必需/可选  | 
数据类型  | 
描述  | 
|---|---|---|---|
gateway  | 
必需  | 
DeviceIdentfier 结构体  | 
需要添加子设备的网关信息,其结构参见 DeviceIdentfier 结构体。  | 
requireSecret  | 
可选  | 
Boolean  | 
  | 
expression  | 
可选  | 
String  | 
查询表达式,目前支持的字段有  
  | 
pagination  | 
可选  | 
Pagination 请求结构体  | 
分页参数。如未指定,默认每页10条。每页最大记录数为200条,但为获得最佳性能,建议每页不超过50条。不支持使用   | 
projection  | 
可选  | 
Projection 结构体  | 
指定对返回结果的裁剪。对于符合条件的搜索仅返回符合条件的字段,不设置则默认返回全部字段。Projection 参数如何对结果集做裁剪>>  | 
DeviceIdentifier 结构体  ¶
备注
以下非必需字段中,必须提供 assetId,或提供 productKey + deviceKey,用于指定设备。
名称  | 
必需/可选  | 
数据类型  | 
描述  | 
|---|---|---|---|
assetId  | 
可选(见上述注解)  | 
String  | 
设备的 asset ID。如何获取 assetId 信息>>  | 
productKey  | 
可选(见上述注解)  | 
String  | 
设备的 product key,需与   | 
deviceKey  | 
可选(见上述注解)  | 
String  | 
设备的 device key,需与   | 
响应参数¶
名称  | 
数据类型  | 
描述  | 
|---|---|---|
data  | 
Device 结构体数组  | 
有关 Device 结构体的定义,其结构参见 Device 结构体。  | 
Device 结构体  ¶
名称  | 
数据类型  | 
描述  | 
|---|---|---|
orgId  | 
String  | 
设备所属的 OU ID。  | 
assetId  | 
String  | 
设备的 asset ID。  | 
modelId  | 
String  | 
设备所属模型 ID。  | 
modelIdPath  | 
String  | 
模型 ID 的路径。  | 
productKey  | 
String  | 
设备的 Product Key。  | 
productName  | 
StringI18n  | 
产品名称。  | 
productType  | 
String  | 
产品类型。  | 
dataFormat (弃用)  | 
String  | 
数据格式。仅支持   | 
deviceKey  | 
String  | 
设备的 Device Key。  | 
deviceName  | 
StringI18n  | 
设备名称。  | 
deviceSecret  | 
String  | 
设备连接密钥,仅当   | 
sessionKey  | 
String  | 
配合解密 deviceSecret 的参数,仅当   | 
deviceDesc  | 
String  | 
设备描述。  | 
timezone  | 
String  | 
设备所在时区。  | 
deviceAttributes  | 
Map(Key 和 Value 为 string)  | 
设备的属性。  | 
deviceTags  | 
Map(Key 和 Value 为 string)  | 
设备的标签。  | 
createTime  | 
Long  | 
设备的创建时间。  | 
status  | 
String  | 
设备的状态(online、offline、inactive、disable)。 
  | 
activeTime  | 
Long  | 
设备的激活时间。  | 
lastOnlineTime  | 
Long  | 
设备最后一次上线时间。  | 
lastOfflineTime  | 
Long  | 
设备最后一次离线时间。  | 
measurepointLastUpdate  | 
Long  | 
设备测点最近一次更新的时间。  | 
attributeLastUpdate  | 
Long  | 
设备属性最近一次更新的时间。  | 
featureLastUpdate  | 
Long  | 
设备最近一次更新的时间,以上述三个时间(   | 
firmwareVersion  | 
String  | 
固件版本号。  | 
错误码¶
代码  | 
错误信息  | 
描述  | 
|---|---|---|
11738  | 
Not Gateway  | 
参数 gateway 指定的设备不是网关。  | 
99400  | 
Invalid arguments  | 
参数错误。  | 
11858  | 
Unable to find public key  | 
由于应用的服务帐号未创建 RSA 密钥对,无法获取 RSA 公钥,因此无法请求   | 
示例¶
请求示例¶
url:https://{apigw-address}/connect-service/v2.4/device-topos?action=searchSubDevice&orgId=yourOrgId
method: POST
requestBody:
{
    "gateway":{
        "assetId":"yourAssetId"
        },
    "requireSecret": true
}
返回示例¶
{
        "code": 0,
        "msg": "OK",
        "requestId": "498d1c5b-7c4f-401a-a9ff-9072931bec2e",
        "data": [{
            "orgId": "yourOrgId",
            "assetId": "mAEsF3sm",
            "modelId": "AlterTest0617",
            "modelIdPath": "/AlterTest0617",
            "productKey": "yourProductKey",
            "productName": {
                "defaultValue": "AlterTest0617_Product",
                "i18nValue": {}
            },
            "productType": "Device",
            "dataFormat": "Json",
            "deviceKey": "yourDeviceKey",
            "deviceName": {
                "defaultValue": "testforCreatedevice",
                "i18nValue": {}
            },
            "deviceSecret":"EncryptedDeviceSecret1",
            "sessionKey":"EncryptedSessionKey1",
            "deviceDesc": "test for createdevice",
            "timezone": "+08:00",
            "deviceAttributes": {
                "testatt": 111111
            },
            "deviceTags": {},
            "firmwareVersion": null,
            "createTime": 1560755091998,
            "status": "inactive",
            "activeTime": 0,
            "lastOnlineTime": 0,
            "lastOfflineTime": 0,
            "measurepointLastUpdate": null,
            "attributeLastUpdate": null,
            "featureLastUpdate": null
        }, {
            "orgId": "yourOrgId",
            "assetId": "gVRwKQ3C",
            "modelId": "AlterTest0617",
            "modelIdPath": "/AlterTest0617",
            "productKey": "yourProductKey",
            "productName": {
                "defaultValue": "AlterTest0617_Product",
                "i18nValue": {}
            },
            "productType": "Device",
            "dataFormat": "Json",
            "deviceKey": "yourDeviceKey",
            "deviceName": {
                "defaultValue": "AlterTest0617_Product",
                "i18nValue": {}
            },
            "deviceSecret":"EncryptedDeviceSecret2",
            "sessionKey":"EncryptedSessionKey2",
            "deviceDesc": null,
            "timezone": "+10:00",
            "deviceAttributes": {},
            "deviceTags": {},
            "firmwareVersion": null,
            "createTime": 1560730295671,
            "status": "offline",
            "activeTime": 1560730567958,
            "lastOnlineTime": 1560743932166,
            "lastOfflineTime": 1560744112166,
            "measurepointLastUpdate": null,
            "attributeLastUpdate": null,
            "featureLastUpdate": null
        }],
        "pagination":{"sortedBy":null,"pageNo":1,"pageSize":2,"totalSize":2}}