Get Asset DI Data Duration¶
Get the duration of different status (DI) data of specified devices within a certain period.
Operation Permissions¶
Required Authorization |
Required Operation Permission |
---|---|
Asset |
Read |
For more information about resources and required permission, see Policies, Roles and Permissions>>
Request Format¶
POST https://{apigw-address}/tsdb-service/v2.1/di/duration
Request Parameters (URI)¶
Name |
Location (Path/Query) |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|---|
orgId |
Query |
Mandatory |
String |
The organization ID which the asset belongs to. How to get organization ID>> |
Request Parameters (Body)¶
Name |
Mandatory/Optional |
Data Type |
Description |
---|---|---|---|
modelId |
Optional |
String |
The model ID. How to get modelID>> |
assetIds |
Mandatory |
String |
The asset ID. Supports the query of multiple asset IDs, separated by commas. How to get assetId>> |
pointIds |
Mandatory |
String |
The measurement point ID. Supports the query of multiple measurement point IDs, separated by commas. How to get pointId>> |
startTime |
Mandatory |
String |
The start time of the sampling data, where both UTC and local time formats are supported. For UTC time format, the application will query all the asset data by the unified start timestamp and end timestamp. Timezone information is required for the UTC time format: 2019-06-01T00:00:00+08:00. For local time format, the application will query the asset data by the local time of where the device is located. Its format is: YYYY-MM-DD HH:MM:SS. |
endTime |
Mandatory |
String |
The end time of the sampling data. Its format must be consistent with |
status |
Optional |
String |
Filter results that include multiple status durations. For example, if only the results of status 0 are required, set the value as “0”. Multiple status are supported. Separate the status by commas. |
ifWithUnknown |
Optional |
Boolean |
When the status cannot be confirmed for a certain period of time, the status is “Unknown”. true (default) = includes the “Unknown” status in the response. false = does not include the “Unknown” status in the response. |
Response Parameters¶
Name |
Data Type |
Description |
---|---|---|
data |
List<JSONObject> |
The list of asset data. The data returned for a single point of a single device is sorted by the data timestamp in ascending order. For more information, see items |
items¶
Sample¶
{
"scanEndTimestamp": 1569859800000,
"pointId": "yourPointId",
"assetId": "yourAssetId",
"durations": [
{
"duration": 60000,
"status": 0
},
{
"duration": 60000,
"status": 1
}
]
}
Parameters¶
Name |
Data Type |
Description |
---|---|---|
scanEndTimestamp |
Long |
The timestamp of the last data to be scanned. The total number of data for one time scan must not exceed 640000. When the data exceeds 640000, the scan is stopped. This parameter returns the timestamp of the last data scanned, indicating the data after this timestamp are not included. |
assetId |
String |
The asset ID. |
pointId |
String |
The measurement point ID. |
durations |
List<JSONObject> |
A list of the durations of different statuses. |
status |
Integer |
The value of the measurement point of the device. |
duration |
Integer |
The duration of the above |
Error Codes¶
For description of error codes, see Common Error Codes.
Sample 1¶
Request Sample¶
When ifWithUnknown
is true:
url: https://{apigw-address}/tsdb-service/v2.1/di/duration?orgId=yourOrgId
method: POST
Content-Type: application/json
requestBody:
{
"assetIds": "yourAssetId1,yourAssetId2",
"pointIds": "yourPointIds",
"startTime": "2020-03-01 00:00:00",
"endTime": "2020-03-02 00:00:00",
"status": "0,1",
"ifWithUnknown": true,
"localTimeFormat": 1,
"itemFormat": 0
}
Return Sample¶
{
"code": 0,
"msg": "OK",
"submsg": null,
"data": {
"items": [
{
"scanEndTimestamp": 1583082072000,
"pointId": "yourPointId",
"assetId": "yourAssetId1",
"durations": [
{
"duration": 60000,
"status": 0
},
{
"duration": 60000,
"status": 1
},
{
"duration": 180000,
"status": "Unknown"
}
]
},
{
"scanEndTimestamp": 1583082072000,
"pointId": "yourPointId",
"assetId": "yourAssetId2",
"durations": [
{
"duration": 60000,
"status": 0
},
{
"duration": 60000,
"status": 1
},
{
"duration": 180000,
"status": "Unknown"
}
]
}
]
}
}
Sample 2¶
Request Sample¶
When ifWithUnknown
is false:
url: https://{apigw-address}/tsdb-service/v2.1/di/duration?orgId=yourOrgId
method: POST
Content-Type: application/json
requestBody:
{
"assetIds": "yourAssetId1,yourAssetId2",
"pointIds": "yourPointIds",
"startTime": "2020-03-01 00:00:00",
"endTime": "2020-03-02 00:00:00",
"status": "0,1",
"ifWithUnknown": false,
"localTimeFormat": 1,
"itemFormat": 0
}
Return Sample¶
{
"code": 0,
"msg": "OK",
"submsg": null,
"data": {
"items": [
{
"scanEndTimestamp": 1583082072000,
"durations": [
{
"duration": 60000,
"status": 0
},
{
"duration": 60000,
"status": 1
}
],
"pointId": "yourPointId",
"assetId": "yourAssetId1"
},
{
"scanEndTimestamp": 1583082072000,
"durations": [
{
"duration": 60000,
"status": 0
},
{
"duration": 60000,
"status": 1
}
],
"pointId": "yourPointId",
"assetId": "yourAssetId2"
}
]
}
}
Sample 3¶
Request Sample¶
Filter the status
:
Note
After status filtering, the status “Unknown” will be not inluded in the response.
url: https://{apigw-address}/tsdb-service/v2.1/di/duration?orgId=yourOrgId
method: POST
Content-Type: application/json
requestBody:
{
"assetIds": "yourAssetId1,yourAssetId2",
"pointIds": "yourPointIds",
"startTime": "2020-03-01 00:00:00",
"endTime": "2020-03-02 00:00:00",
"status": "1",
"localTimeFormat": 1,
"itemFormat": 0
}
Return Sample¶
{
"code": 0,
"msg": "OK",
"submsg": null,
"data": {
"items": [
{
"scanEndTimestamp": 1583082072000,
"durations": [
{
"duration": 60000,
"status": 1
}
],
"pointId": "yourPointId",
"assetId": "yourAssetId1"
},
{
"scanEndTimestamp": 1583082072000,
"durations": [
{
"duration": 60000,
"status": 1
}
],
"pointId": "yourPointId",
"assetId": "yourAssetId2"
}
]
}
}
SDK Samples¶
You can access the `Java SDK Samples<https://github.com/EnvisionIot/sample-code-java/tree/EnOS2.4/tsdbdata>`__for TSDB data service on Github.