Energy Consumption Management

Last Updated on : 2024-08-28 07:33:38download

This topic describes APIs related to energy consumption management.

API list

Request method API endpoint Description
GET /v1.0/illumination/space/energy/query Queries energy consumption of a space.
POST /v1.0/cloud/illume/open/energy/device Queries energy consumption of a device.

Query space energy consumption

API description

Query the energy consumption data of a space over a specific time period.

  • Comparison with same day previous week: Displays the energy consumption data of one day in comparison with that of the same day in the previous week.
  • Comparison with same month previous year: Displays the energy consumption data of one month in comparison with that of the same month in the previous year.
  • Comparison with previous day: Displays the energy consumption data of one day in comparison with that of the previous day.
  • Comparison with previous month: Displays the energy consumption data of one month in comparison with that of the previous month.
  • Comparison with previous year: Displays the energy consumption data of one year in comparison with that of the previous year.

API endpoint

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

Request parameters

Parameter Data type Parameter type Description Required
projectId String Body The project ID. Yes
roomId String Body The space ID. No
targetType Integer Body The query type. Valid values:
  • 1: day
  • 2: month
  • 3: year
Yes
startTime Long Body The start time. Yes
endTime Long Body The end time. Yes

Things to note

  • When targetType is 1, the difference between the timestamps must be one day, with one timestamp at 0:00 on one day and the other timestamp at 0:00 on the following day.
  • When targetType is 2, the difference between the timestamps must be 2 to 31 days. That is, the minimum difference is from 0:00 on one day to 0:00 two days later, while the maximum difference is from 0:00 on the first day of a 31-day month to 0:00 on the first day of the following month.
  • When targetType is 3, the difference between the timestamps must be within 12 months. That is, the minimum difference is from January to February, while the maximum difference is from one January to the following January, independent of day or hour.

Response parameters

Parameter Type Description
code Integer The response code. It is empty if the request succeeds. For more information, see Error codes.
success Boolean Indicates whether the request succeeds. Valid values:
  • true: succeeded
  • false: failed
msg String The error message. It is empty if the request succeeds.
t Long The returned 13-digit timestamp.
result Object The returned result.

Description of result

{
  "totalEnergy": "double // The total energy consumption.",
  "averageEnergy": "double // The average energy consumption.",
  "tbValue": "double // The difference between the current period and the previous same period.",
  "hbValue": "double // The difference between two consecutive periods.",
  "tb": "double // The comparison between the current period and the previous same period.",
  "hb": "double // The comparison between two consecutive periods.",
  "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": "The query type. 1 for day, 2 for month, and 3 for 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 between the current period and the previous same period.",
  "hbValue": "The difference between two consecutive periods.",
  "tb": "The comparison between the current period and the previous same period.",
  "hb": "The comparison between two consecutive periods.",
  "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."
        }
      ]
    }
  ]
}

Query device energy consumption

API description

Query the energy consumption data of multiple devices.

API endpoint

POST /v1.0/cloud/illume/open/energy/device

Request parameters

Parameter Data type Parameter type Description Required
projectId String Body The project ID. Yes
deviceIds String[] Body The list of device IDs. Yes
period String Body The period. Valid values:
  • day: a specific day
  • week: this week
  • month: this month
  • year: this year
  • custom_day: a custom day
energyType Integer Body The energy consumption type. Valid values:
  • electricity: electricity
  • water: water
  • gas: gas
Yes
startTime Long Body The start time.
  • For day, week, and custom_day, the format is yyyyMMdd.
  • For month and year, the format is yyyyMM.
Yes
endTime Long Body The end time.
  • For day, week, and custom_day, the format is yyyyMMdd.
  • For month and year, the format is yyyyMM.
Yes

Response parameters

Parameter Type Description
code Integer The response code. It is empty if the request succeeds. For more information, see Error codes.
success Boolean Indicates whether the request succeeds. Valid values:
  • true: succeeded
  • false: failed
msg String The error message. It is empty if the request succeeds.
t Long The returned 13-digit timestamp.
result Object The returned result.

Description of result

{
  "totalEnergy": "String // The total energy consumption.",
  "averageEnergy": "String // The average energy consumption.",
  "energyDetail": [
    {
      "energy": "String // The energy consumption.",
      "theoryEnergy": "String // The theoretical energy consumption.",
      "theoryRadio": "String // The theoretical energy consumption ratio.",
      "time": "String // The date."
    }
  ]
}

Sample request

{
  "projectId": "1793201629403611***",
  "deviceIds": [
    "6cc4908944f7e67dadg***"
  ],
  "period": "day",
  "energyType": "electricity",
  "startTime": "20240724",
  "endTime": "20240724"
}

Sample response

{
  "result": {
    "averageEnergy": "0.002",
    "energyDetail": [
      {
        "energy": "0.002",
        "theoryEnergy": "0.012",
        "theoryRadio": "0.857",
        "time": 2024072400
      },
      {
        "energy": "0.000",
        "theoryEnergy": "--",
        "theoryRadio": "--",
        "time": 2024072416
      }
    ],
    "totalEnergy": "0.028"
  },
  "success": true,
  "t": 1721807661231,
  "tid": "ef604ae2499111efb454526982c4e3fa"
}

Error codes

The following table lists the error codes that might be returned when you call these APIs. For more information, see Global Error Codes.

Error code Description
500 A system error occurred.