Energy Consumption Management

Last Updated on : 2021-11-09 02:08:42download

This topic describes the API operations that are used to manage energy consumption.

API list

Request method API Description
GET /v1.0/illumination/space/energy/query Query the energy consumption in a specified space.

Query energy consumption

API description

Query energy consumption data in a certain period within a specified space.

Things to note

  • When targetType is 1, the timestamp must be one day, ranging from 0:00 on the day to 0:00 the next day.

  • When targetType is 2, the timestamp must be 2 to 31 days. That is, the minimum value is 0:00 on the day to 0:00 the day after tomorrow, and the maximum value is 0:00 on the 1st day of this month to 0:00 on the 1st day of the following month. The maximum value is 31 for one odd month.

  • When targetType is 3, the timestamp must be within 12 months. That is, the minimum value is from January to February, and the maximum value is from this January to the next January, independent of day or hour.

  • Compared with the same day of last week: Compare the data of the day with that of the same day in last week.

  • Compared with the same month of last year: Compare the data of this month with that of the same month in last year.

  • Compared with yesterday: Compare the data of the day with that of yesterday.

  • Compared with last month: Compare the data of this month with that of last month.

  • Compared with last year: Compare the data of this year with that of last year.

API endpoint

GET /v1.0/illumination/space/energy/query

Request parameter

Parameter Type Parameter type Description Required
projectId String body The project ID true
roomId String body The ID of a specified space. false
targetType int body The query type. Valid values:
  • 1: by day.
  • 2: by month.
  • 3: by year.
true
startTime long body The start time. true
endTime long body The end time. true

Return parameter

Parameter Type Description
code Integer The error code. For more information, see the error code section. It is null when the operation succeeded.
success Boolean Indicates whether the operation is successful. Valid values:
  • true: succeeded.
  • false: failed.
msg String The message that is returned if the request fails. It will return null if the request succeeds.
t Long The returned 13-bit timestamp.
result Object The returned result.

Description of the result parameter

{
  "totalEnergy": "double // The total energy consumption",
  "averageEnergy": "double // The average energy consumption",
  "tbValue": "double // The difference in the same period",
  "hbValue": "double // The difference between periods",
  "tb": "double // Compared with the same period of the last statistical cycle",
  "hb": "double // Compared with last statistical cycle",
  "data": [
    {
      "sort": "int // The sorting field",
      "time": "long // The timestamp",
      "totalEnergy": "double // The total energy consumption",
      "data": [
        {
          "purposeCode": "int // The purpose",
          "i18nName": "String // The multilingual name",
          "energy": "double // The energy consumption"
        }
      ]
    }
  ]
}

Sample request

{
  "targetType": "Query type. 1: by day, 2: by month, and 3: by year",
  "startTime": "The start time",
  "endTime": "The end time",
  "projectId": "The project ID",
  "roomId": "The space ID"
}

Sample response

{
  "totalEnergy": "The total energy consumption",
  "averageEnergy": "The average energy consumption",
  "tbValue": "The difference in the same period",
  "hbValue": "The difference between periods",
  "tb": "Compared with the same period of the last statistical cycle",
  "hb": "Compared with last statistical cycle",
  "data": [
    {
      "sort": "The sorting field",
      "time": "The timestamp",
      "totalEnergy": "The total energy consumption",
      "data": [
        {
          "purposeCode": "The purpose",
          "i18nName": "The multilingual name",
          "Energy": "The energy consumption",
        }
      ]
    }
  ]
}

Error codes

The following table describes common error codes for this API operation. For more information, see Global Error Codes.

Error code Description
500 A system error has occurred while processing your request.