查询设备功能历史上报⽇志

更新时间:2023-05-22 06:38:25下载pdf

您可以调用 通用接口 查询设备功能最近的历史上报⽇志,目前只能查询近 7 天的数据。

接口说明

接口名称 版本 说明
tuya.m.smart.operate.all.log 1.0 查询设备功能历史上报日志

业务参数

名称 类型 描述 是否必填
devId String 设备 ID
dpIds String 要查询的设备功能,即 DP(Data Point),按逗号分隔,例如 @“1,2”
offset Integer 分页偏移量
limit Integer 分页大小, 指返回结果一页的数据条数
startTime String 设备上报的时间,查询起始时间,单位为毫秒
endTime String 设备上报的时间,查询截止时间,单位为毫秒
sortType String 按时间排序方式:
  • ASC:升序排列
  • DESC:降序排列
默认值:DESC

请求示例

{
  "devId" : "05200020b4e62d16ce8b",
  "dpIds" : "1,2",
  "offset" : 0,
  "limit" : 10,
  "startTime" : "1542800401000",
  "endTime" : "1542886801000",
  "sortType" : "DESC"
}

响应示例

{
  "result" : {
    "total" : 11055,
    "dps" : [ {
      "timeStamp" : 1542829972,
      "dpId" : 5,
      "timeStr" : "2018-11-21 20:52:52",
      "value" : "311"
    }, {
      "timeStamp" : 1542829970,
      "dpId" : 5,
      "timeStr" : "2018-11-21 20:52:50",
      "value" : "323"
    }, {
      "timeStamp" : 1542829966,
      "dpId" : 5,
      "timeStr" : "2018-11-21 20:52:46",
      "value" : "230"
    }, {
      "timeStamp" : 1542829964,
      "dpId" : 5,
      "timeStr" : "2018-11-21 20:52:44",
      "value" : "231"
    }, {
      "timeStamp" : 1542829960,
      "dpId" : 5,
      "timeStr" : "2018-11-21 20:52:40",
      "value" : "307"
    }, {
      "timeStamp" : 1542829958,
      "dpId" : 5,
      "timeStr" : "2018-11-21 20:52:38",
      "value" : "320"
    }, {
      "timeStamp" : 1542829954,
      "dpId" : 5,
      "timeStr" : "2018-11-21 20:52:34",
      "value" : "229"
    }, {
      "timeStamp" : 1542829950,
      "dpId" : 5,
      "timeStr" : "2018-11-21 20:52:30",
      "value" : "325"
    }, {
      "timeStamp" : 1542829948,
      "dpId" : 5,
      "timeStr" : "2018-11-21 20:52:28",
      "value" : "292"
    }, {
      "timeStamp" : 1542829942,
      "dpId" : 5,
      "timeStr" : "2018-11-21 20:52:22",
      "value" : "231"
    } ],
    "hasNext" : true
  },
  "t" : 1542959314632,
  "success" : true,
  "status" : "ok"
}

代码示例

Objective C

- (void)getOperationLogList {

  [[TuyaSmartRequest new] requestWithApiName:@"tuya.m.smart.operate.all.log" postData:@{@"devId":@"", @"dpIds":@"1", @"offset":@(0), @"limit":@(10)} version:@"1.0" success:^(id result) {

  } failure:^(NSError *error) {

  }];

}

Swift

func getOperationLogList() {

    TuyaSmartRequest().init(apiName: "tuya.m.smart.operate.all.log", postData: [:], version: "1.0", success: { result in

    }, failure: { error in

    })
}