该接口用于发送读取属性指令到已连接的设备。设备端接收到指令后需回复。
读取设备属性的回复如下:
Topic:/{productId}/{deviceId}/properties/read/reply
方向:上行
注意
设备回复后会修改属性。
请求接口
POST /api/device/instance/{deviceId}/properties/_read
请求参数
名称 | 位置 | 类型 | 必选 | 说明 |
---|---|---|---|---|
X-Access-Token | header | string | true | 平台 token |
deviceId | path | string | true | 设备ID |
strings | body | object | true | string,请求示例: ["属性ID"] |
响应参数
以200 Response为例,响应参数如下:
名称 | 类型 | 说明 |
---|---|---|
»message | string | 返回信息 |
»status | integer(int32) | 响应状态码 |
»code | string | 业务码 |
»timestamp | integer(int64) | 时间戳(毫秒) |
响应状态码
状态码 | 状态码含义 | 说明 |
---|---|---|
200 | OK | 成功 |
401 | Unauthorized | 登录状态已过期,token不能为空 |
500 | Internal Server Error | 服务器内部异常 |
Body示例
json
["real_state_ram_usage_rate"]
["real_state_ram_usage_rate"]
使用示例
发送读取设备属性指令:
Topic: /testMQTT/one/properties/read
方向:下行(平台下发)
json
{
"headers":{
"deviceName":"one",
"productName":"testMQTT",
"productId":"testMQTT",
"_uid":"AYmwg4H2-Cnkb4JQfWy1nO4j-RDyOVQX",
"creatorId":"1199596756811550720",
"traceparent":"00-9cadced9ef7acc7b5ee92247e24cff06-7cbee56572962fb4-01"
},
"messageId":"1686313972204158977",
"deviceId":"one",
"timestamp":1690883555829,
"properties":[],
"messageType":"READ_PROPERTY"
}
{
"headers":{
"deviceName":"one",
"productName":"testMQTT",
"productId":"testMQTT",
"_uid":"AYmwg4H2-Cnkb4JQfWy1nO4j-RDyOVQX",
"creatorId":"1199596756811550720",
"traceparent":"00-9cadced9ef7acc7b5ee92247e24cff06-7cbee56572962fb4-01"
},
"messageId":"1686313972204158977",
"deviceId":"one",
"timestamp":1690883555829,
"properties":[],
"messageType":"READ_PROPERTY"
}
读取设备属性后,设备回复:
Topic: /testMQTT/one/properties/read/reply
方向:上行
json
{
"messageId":"1686339679198232577",
"deviceId":"one",
"properties":{
"real_state_ram_usage_rate":"1"
},
"success":true
}
{
"messageId":"1686339679198232577",
"deviceId":"one",
"properties":{
"real_state_ram_usage_rate":"1"
},
"success":true
}
返回示例
- 200 Response
json
{
"message": "success",
"result": {
"real_state_ram_usage_rate": "1"
},
"status": 200,
"timestamp": 1690889692447
}
{
"message": "success",
"result": {
"real_state_ram_usage_rate": "1"
},
"status": 200,
"timestamp": 1690889692447
}
- 500 Response(设备端超时未响应)
json
{
"message": "超时",
"status": 500,
"code": "time_out",
"timestamp": 1690883565831
}
{
"message": "超时",
"status": 500,
"code": "time_out",
"timestamp": 1690883565831
}