设备影子
大约 2 分钟
设备影子
获取设备影子
GET | /admin-api/iot/device-info/list |
---|
请求数据类型 :application/json;charset=UTF-8
请求参数
参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 |
---|---|---|---|---|
productKey | 查询指定产品productKey的设备,productId和productKey只需要传一个就可以 | json | true | string |
deviceName | 模糊查询指定设备的deviceName | json | true | string |
Authorization | 认证 Token,示例值(Bearer be080642804d4af285ccccaefcb66eda) 获取access_token请参考获取访问令牌 | header | true | string |
响应状态
状态码 | 说明 |
---|---|
200 | OK |
响应参数
参数名称 | 参数说明 | 数据类型 |
---|---|---|
status | 状态码,值为0正常,其他值为异常 | int |
code | 结果同status一样,冗余字段 | int |
data | 数据体 | object |
---id | id | long |
---deviceId | 设备id | long |
---deviceName | 设备唯一名称 | string |
---productId | 产品ID | long |
---productKey | productKey | string |
---shadow | 设备影子;格式为JSON字符串 | string |
---createTime | 创建时间,时间戳,时间戳13位 | long |
---updateTime | 更新时间,时间戳,时间戳13位 | long |
msg | 状态消息 | string |
响应示例
{
"status": 0,
"code": 0,
"data": {
"shadow": "{\n \"state\": {\n \"reported\": {},\n \"desired\": {}\n },\n \"metadata\": {\n \"reported\": {},\n \"desired\": {}\n },\n \"timestamp\": 0,\n \"version\": 0\n}",
"productId": 1414626985410560,
"deviceId": 1420138037510144,
"productKey": "WSaSUV",
"deviceName": "testt",
"id": 1420138037837824,
"createTime": 1733566941000,
"updateTime": 1733566941000
},
"msg": ""
}
shadow格式字符串含义
{
"metadata": {
"desired": {
"test": {//期望设备影子的key
"timestamp": 1734173605598
}
},
"reported": {} //设备上传的key信息
},
"state": {
"desired": {
"test": 1 //期望设备影子的数据
},
"reported": {}//设备上传的key数据
},
"version": 1,//设备影子版本
"timestamp": 1734173605598//最新一次更新的时间戳
}
更新设备影子期望值
PUT | /admin-api/iot/shadow/update |
---|
请求数据类型 :application/json;charset=UTF-8
请求参数
参数名称 | 参数说明 | 请求类型 | 是否必须 | 数据类型 |
---|---|---|---|---|
productKey | 查询指定产品productKey的设备,productId和productKey只需要传一个就可以 | json | true | string |
deviceName | 模糊查询指定设备的deviceName | json | true | string |
desired | 应用程序改变设备期望值,格式为JSON字符串,如:{ "rrr": 2, "test": 1 } | json | true | string |
Authorization | 认证 Token,示例值(Bearer be080642804d4af285ccccaefcb66eda) 获取access_token请参考获取访问令牌 | header | true | string |
响应状态
状态码 | 说明 |
---|---|
200 | OK |
响应参数
参数名称 | 参数说明 | 数据类型 |
---|---|---|
status | 状态码,值为0正常,其他值为异常 | int |
code | 结果同status一样,冗余字段 | int |
data | 更新成功返回true | boolean |
msg | 状态消息 | string |
响应示例
{
"status": 0,
"code": 0,
"data": true,
"msg": ""
}