Query Reported DP Logs

Last Updated on : 2024-04-03 06:15:28download

Returns the logs of data points (DPs) reported by a device. The logs only in the last seven days are supported. Common API requests are made to get the logs.

API description

API name Version Description
tuya.m.smart.operate.all.log v1.0 Query DP logs

Request parameters

Name Type Description Required
devId String The device ID. Yes
dpIds String The DPs to be returned, separated with commas (,). Example: @"1,2". Yes
offset Integer The number of entries starting from which entries are returned. Yes
limit Integer The number of entries to be returned per page. Yes
startTime String The time when DP status reporting starts. Unit: milliseconds. No
endTime String The time when DP status reporting ends. Unit: milliseconds. No
sortType String The method to sort data by time. Valid values:
  • ASC: sorted in ascending order
  • DESC: sorted in descending order
Default value: DESC.
No

The sum of the values of offset and limit cannot exceed 1000.

Sample request

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

Sample response

{
  "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"
}

Example for Java

Map<String, Object> map = new HashMap<>();
map.put("devId", "your_devId");
map.put("dpIds", "your_device_dpId_str"); //"1,2"
//map.put("..","..");

TuyaHomeSdk.getRequestInstance().requestWithApiName("tuya.m.smart.operate.all.log", "1.0", map, String.class, new ITuyaDataCallback<String>() {
    @Override
    public void onSuccess(String result) {

    }

    @Override
    public void onError(String s, String s1) {

    }
});