Skip to content

读取设备属性 (POST)

更新时间:

该接口用于发送读取属性指令到已连接的设备。设备端接收到指令后需回复。

读取设备属性的回复如下:

Topic/{productId}/{deviceId}/properties/read/reply

方向:上行

注意

设备回复后会修改属性。

请求接口

POST /api/device/instance/{deviceId}/properties/_read

TIP

访问权限:需要登录超级设备管理平台获取token,并校验token

请求参数

名称位置类型必选说明
X-Access-Tokenheaderstringtrue平台 token
deviceIdpathstringtrue设备ID
stringsbodyobjecttruestring,请求示例: ["属性ID"]

响应参数

以200 Response为例,响应参数如下:

名称类型说明
»messagestring返回信息
»statusinteger(int32)响应状态码
»codestring业务码
»timestampinteger(int64)时间戳(毫秒)

响应状态码

状态码状态码含义说明
200OK成功
401Unauthorized登录状态已过期,token不能为空
500Internal 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
}