Get Asset Current Day Electric Power¶
Get the accumulated power consumption/production data of a specified device from 00:00 (local time) to current time.
Operation Permissions¶
Required Authorization |
Required Operation Permission |
---|---|
Asset |
Read |
Request Format¶
GET https://{apigw-address}/tsdb-service/v2.0/electric-power/current-day?orgId={}&modelId={}&assetIds={}&measurepoints={}&accessKey={}&localTimeAccuracy={}
Request Parameters (URI)¶
Name |
Location (Path/Query) |
Required or Not |
Data Type |
Description |
---|---|---|---|---|
orgId |
Query |
true |
String |
Organization ID which the asset belongs to. How to get orgId>> |
modelId |
Query |
false |
String |
Model ID which the asset belongs to. How to get modelID>> |
assetIds |
Query |
true |
String |
Asset ID, which supports querying multiple assets; multiple asset IDs are separated by commas. How to get assetId>> |
measurepoints |
Query |
true |
String |
Asset measurement point. It is supported to query multiple measurement points, and all the measurement points are separated by commas; the upper limit for query is 3000 (Number of devices *Number of measurement points). How to get pointId>> |
accessKey |
Query |
false |
String |
Service account of the application. The application authenticates with |
localTimeAccuracy |
Query |
false |
Boolean |
Specify whether query returns data with millisecond time stamp. |
Response Parameters¶
Name |
Data Type |
Description |
---|---|---|
items |
|
List of asset data. The data returned for a single point of a single device is sorted by time in ascending order. Parameters are stored in the Object struct. See items. |
items¶
Sample¶
{
"assetId": "4DXYH7nS",
"timestamp": 1560329220000,
"opentsdb_pi_point_xxx": "10.615000000000002"
}
Parameters¶
Name |
Data Type |
Description |
---|---|---|
assetId |
String |
Asset ID |
pointId |
Object |
This parameter is a variable, indicating the identifier and data for the measurement point. The data here is the daily aggregation of the sum of power consumption/production data. |
timestamp |
String |
Data timestamp (UNIX time, accurate to second) |
Error Codes¶
For description of error codes, see Common Error Codes.
Sample¶
Request Sample¶
GET
https://{apigw-address}/tsdb-service/v2.0/electric-power/current-day?orgId=o15504722874071&modelId=&assetIds=4DXYH7nS&measurepoints=opentsdb_pi_point_xxx&accessKey=accessKey
Return Sample¶
{
"status": 0,
"requestId": null,
"msg": "success",
"submsg": null,
"data": {
"items": [
{
"assetId": "4DXYH7nS",
"timestamp": 1560329220000,
"sum(opentsdb_pi_point_xxx)": "10.615000000000002"
}
]
}
}
Java SDK Sample¶
private static class Request extends PoseidonRequest{
public void setQueryParam(String key, Object value){
queryEncodeParams().put(key, value);
}
public void setMethod(String method) {
this.method = method;
}
private String method;
@Override
public String baseUri() {
return "";
}
@Override
public String method() {
return method;
}
}
@Test
public void getAssetsCurrentDayElectricPowerTest(){
//1. Click Application Registration in the left navigation of the EnOS Management Console.
//2. Click the application that needs to call the API, and click Basic Information. accessKey and secretKey correspond to AccessKey and SecretKey in EnOS.
String accessKey = "29b8d283-dddd-4c31f0e3a356-0f80-4fdf";
String secretKey = "f0e3a856-0fc0-4fdf-b1e5-b34da152879c";
//New a request and pass the required parameters into the map that exists in the query. The key is the parameter name and the value is the parameter value.
Request request = new Request();
request.setQueryParam("orgId", "yourOrgId");
request.setQueryParam("modelId", "model_xxx");
request.setQueryParam("assetIds","4DXYH7nS");
request.setQueryParam("measurepoints", "opentsdb_pi_point_xxx");
request.setQueryParam("accessKey", accessKey);
request.setMethod("GET");
try {
JSONObject response = Poseidon.config(PConfig.init().appKey(accessKey).appSecret(secretKey).debug())
.url("http://apim-gateway/tsdb-service/v2.0/electric-power/current-day")
.getResponse(request, JSONObject.class);
System.out.println(response);
} catch (Exception e) {
e.printStackTrace();
}
}