V2.1 Search Device¶
查询设备信息。
如果你在使用 API 批量更新相关设备信息后调用当前 API,建议两次调用间隔 2 秒左右,以免获取到未更新数据。
当前 API 支持在 EnOS 2.1.0 及以上环境中使用,并已新增 V2.4 版本。推荐使用最新版本,参见 V2.4 Search Device。
请求格式¶
POST https://{apigw-address}/connect-service/v2.1/devices?action=search
请求参数(URI)¶
| 名称 | 位置(Path/Query) | 必需/可选 | 数据类型 | 描述 | 
|---|---|---|---|---|
| orgId | Query | 必需 | String | 资产所属的组织 ID。如何获取 orgId 信息>> | 
请求参数(Body)¶
| 名称 | 必需/可选 | 数据类型 | 描述 | 
|---|---|---|---|
| expression | 可选 | String | 查询表达式,目前支持的字段有   
 | 
| pagination | 可选 | Pagination 请求结构体 | 随机分页。如未指定,默认每页 10 条。每页最大记录数为 1,000 条,但为获得最佳性能,建议每页不超过 50 条。EnOS Edge 单页最大上限为 3,000 条。不支持使用  | 
| projection | 可选 | Projection 结构体 | 指定对返回结果的裁剪。对于符合条件的搜索仅返回符合条件的字段,不设置则默认返回全部字段。EnOS Edge 不支持多层字段的裁剪,只取最外层字段。Projection 参数如何对结果集做裁剪>> | 
| populateLastUpdateInfo | 可选 | Boolean | 
 | 
响应参数¶
| 名称 | 数据类型 | 描述 | 
|---|---|---|
| data | Device 结构体数组 | 有关 Device 结构体的定义,参见 Device 结构体。 | 
Device 结构体¶
| 名称 | 数据类型 | 描述 | 
|---|---|---|
| orgId | String | 资产所属的组织 ID。 | 
| assetId | String | 资产 ID。 | 
| modelId | String | 资产所属模型 ID。 | 
| modelIdPath | String | 模型 ID 的路径。 | 
| productKey | String | Product Key。 | 
| productName | StringI18n | 产品名称。 
 | 
| productType | String | 产品类型。 
 | 
| dataFormat | String | 数据格式。Custom 表示支持用户自定义数据格式,Json 表示只支持 EnOS 设备协议格式。 
 | 
| deviceKey | String | Device Key。如何获取设备的 deviceKey 信息>> | 
| deviceName | StringI18n | 设备名称。 注:EnOS Edge 不支持返回该字段。 | 
| deviceSecret | String | 设备的连接秘钥。 | 
| deviceDesc | String | 设备描述。 注:EnOS Edge 不支持返回该字段。 | 
| timezone | String | 设备所在时区。 | 
| deviceAttributes | Map(Key 和 Value 为 string) | 设备的属性。 | 
| deviceTags | Map(Key 和 Value 为 string) | 设备的标签。 | 
| mirrorSource | String | 镜像源设备的 device key。 
 | 
| createTime | Long | 设备的创建时间。 
 | 
| status | String | 设备的状态(online、offline、inactive、disable 或 mirror)。 
 | 
| activeTime | Long | 设备的激活时间。 
 | 
| lastOnlineTime | Long | 设备最后一次上线时间。 
 | 
| lastOfflineTime | Long | 设备最后一次离线时间。 
 | 
| measurepointLastUpdate | Long | 设备测点最近一次更新的时间。 
 | 
| eventLastUpdate | Long | 设备事件最近一次更新的时间。 
 | 
| attributeLastUpdate | Long | 设备属性最近一次更新的时间。 
 | 
| featureLastUpdate | Long | 设备最近一次更新的时间,以上述三个时间(  
 | 
| firmwareVersion | String | 固件版本号。 
 | 
示例¶
请求示例¶
url:https://{apigw-address}/connect-service/v2.1/devices?action=search&orgId=yourOrgId
method: POST
requestBody:
{
    "pagination":{
        "pageNo":2,
        "pageSize":5
    },
    "populateLastUpdateInfo": true
}
返回示例¶
{
    "code":0,
    "msg":"OK",
    "requestId":"59ecd409-7baa-4726-ba10-c0bde35ffb09",
    "data":[
        {
            "orgId":"yourOrgId",
            "assetId":"yourAssetId",
            "modelId":"lxctimelooker",
            "modelIdPath":"/lxctimelooker",
            "productKey":"yourProductKey",
            "productName":{
                "defaultValue":"lxcpro",
                "i18nValue":{
                }
            },
            "productType":"Device",
            "dataFormat":"Json",
            "deviceKey":"yourDeviceKey",
            "deviceName":{
                "defaultValue":"time2dev11",
                "i18nValue":{
                }
            },
            "deviceSecret":"yourDeviceSecret",
            "deviceDesc":null,
            "timezone":"+09:00",
            "deviceAttributes":{
            },
            "deviceTags":{
            },
            "createTime":1558421750575,
            "status":"offline",
            "activeTime":1558482329972,
            "lastOnlineTime":1560743915454,
            "lastOfflineTime":1560744095454,
            "measurepointLastUpdate":null,
            "eventLastUpdate":null,
            "attributeLastUpdate":null,
            "featureLastUpdate":null,
            "firmwareVersion": "2.2"
        },
        {
            "orgId":"yourOrgId",
            "assetId":"Fi0HQ8FO",
            "modelId":"AlterTest0615",
            "modelIdPath":"/AlterTest0615",
            "productKey":"yourProductKey",
            "productName":{
                "defaultValue":"AlterTest0615_Product",
                "i18nValue":{
                }
            },
            "productType":"Device",
            "dataFormat":"Json",
            "deviceKey":"yourDeviceKey",
            "deviceName":{
                "defaultValue":"AlterTest0615",
                "i18nValue":{
                }
            },
            "deviceSecret":"yourDeviceSecret",
            "deviceDesc":null,
            "timezone":"+08:00",
            "deviceAttributes":{
            },
            "deviceTags":{
            },
            "createTime":1560564762147,
            "status":"offline",
            "activeTime":1560564838673,
            "lastOnlineTime":1560743931247,
            "lastOfflineTime":1560743931712,
            "measurepointLastUpdate":null,
            "eventLastUpdate":null,
            "attributeLastUpdate":null,
            "featureLastUpdate":null,
            "firmwareVersion": "2.2"
        },
        {
            "orgId":"yourOrgId",
            "assetId":"6FytqleL",
            "modelId":"AlterTest0614",
            "modelIdPath":"/AlterTest0614",
            "productKey":"yourProductKey",
            "productName":{
                "defaultValue":"AlterTest0614_Product",
                "i18nValue":{
                }
            },
            "productType":"Device",
            "dataFormat":"Json",
            "deviceKey":"yourDeviceKey",
            "deviceName":{
                "defaultValue":"AlterTest0614",
                "i18nValue":{
                }
            },
            "deviceSecret":"yourDeviceSecret",
            "deviceDesc":null,
            "timezone":"+08:00",
            "deviceAttributes":{
                "aaa":1,
                "76":0
            },
            "deviceTags":{
            },
            "createTime":1560493341919,
            "status":"offline",
            "activeTime":1560493435761,
            "lastOnlineTime":1560743930253,
            "lastOfflineTime":1560743930346,
            "measurepointLastUpdate":null,
            "eventLastUpdate":null,
            "attributeLastUpdate":null,
            "featureLastUpdate":null,
            "firmwareVersion": "2.2"
        },
        {
            "orgId":"yourOrgId",
            "assetId":"yourAssetId",
            "modelId":"yourModelId",
            "modelIdPath":"yourModelIdPath",
            "productKey":"yourProductKey",
            "productName":{
                "defaultValue":"AlertTest0613_Product",
                "i18nValue":{
                }
            },
            "productType":"Device",
            "dataFormat":"Json",
            "deviceKey":"yourDeviceKey",
            "deviceName":{
                "defaultValue":"AlertTest0613",
                "i18nValue":{
                }
            },
            "deviceSecret":"yourDeviceSecret",
            "deviceDesc":null,
            "timezone":"+08:00",
            "deviceAttributes":{
                "aaa":1,
                "76":0
            },
            "deviceTags":{
            },
            "createTime":1560389949661,
            "status":"offline",
            "activeTime":1560390227903,
            "lastOnlineTime":1560743916848,
            "lastOfflineTime":1560743929003,
            "measurepointLastUpdate":null,
            "eventLastUpdate":null,
            "attributeLastUpdate":null,
            "featureLastUpdate":null,
            "firmwareVersion": "2.2"
        },
        {
            "orgId":"yourOrgId",
            "assetId":"yourAssetId",
            "modelId":"yourModelId",
            "modelIdPath":"yourModelIdPath",
            "productKey":"yourProductKey",
            "productName":{
                "defaultValue":"zccp-----1",
                "i18nValue":{
                }
            },
            "productType":"Device",
            "dataFormat":"Json",
            "deviceKey":"yourDeviceKey",
            "deviceName":{
                "defaultValue":"zccp-----222",
                "i18nValue":{
                }
            },
            "deviceSecret":"yourDeviceSecret",
            "deviceDesc":null,
            "timezone":"+08:00",
            "deviceAttributes":{
                "timestamp1":1,
                "float1":1.0,
                "bool11":false,
                "int1":1,
                "string1":"1",
                "double1":1.0,
                "12221":false,
                "array1":[
                    1
                ],
                "stuct1":{
                    "int11":1
                },
                "file1":"ftp://a.com/demo.txt",
                "enum":1,
                "dete1":"2019-05-06"
            },
            "deviceTags":{
            },
            "createTime":1559294746435,
            "status":"inactive",
            "activeTime":0,
            "lastOnlineTime":0,
            "lastOfflineTime":0,
            "measurepointLastUpdate":null,
            "eventLastUpdate":null,
            "attributeLastUpdate":null,
            "featureLastUpdate":null,
            "firmwareVersion": "2.2"
        }
    ],
    "pagination":{
        "sortedBy":null,
        "pageNo":2,
        "pageSize":5,
        "totalSize":6511
    }
}