English
English
简体中文
Contact Us
Register
Log In
layoutIndex

Energy Consumption Statistics

Last Updated on : 2022-02-17 05:46:38download

Regional energy consumption ranking

Interface Description

Get a ranked list of sub-region energy consumption values for the target region

TuyaCommercialLightingEnergy.getLightingEnergy().requestEnergyAreaRank(
  long projectId,
  long areaId, 
  int targetType, 
  long time, 
  ITuyaResultCallback<ArrayList<EnergyRankBean>> listener);

Parameter Description

parameter name type required description
projectId long true Query the target project id
areaId long true The area id, -1 means all areas, but the return result does not contain unpartitioned
targetType int true 1 means day, 2:month, 3:year
time long true The start time of the time range

Sample code

  TuyaCommercialLightingEnergy.getLightingEnergy().requestEnergyAreaRank(
                10000,
                100,
                1,
                1623826206000L,
                new ITuyaResultCallback<ArrayList<EnergyRankBean>>() {
            @Override
            public void onSuccess(ArrayList<EnergyRankBean> result) {
                Toast.makeText(this, "Get Success", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onError(String errorCode, String errorMessage) {
                Toast.makeText(this, "Failed to get", Toast.LENGTH_SHORT).show();
            }
        });

Sub-energy ranking

Interface description

Get a ranked list of sub-energy values for the target area

TuyaCommercialLightingEnergy.getLightingEnergy().requestEnergySubentryRank(
  long projectId, 
  long areaId, 
  int targetType,
  long time, 
  ITuyaResultCallback<ArrayList<EnergyRankBean>> listener);

Parameter Description

parameter name type required description
projectId long true Query the target project id
areaId long true areaId, -1 means all areas
targetType int true 1 means day, 2:month, 3:year
time long true The start time of the time range

Example code

TuyaCommercialLightingEnergy.getLightingEnergy().requestEnergySubentryRank(10000, 123, 1, 1623826206000, new ITuyaResultCallback<ArrayList<EnergyRankBean>>() {
            @Override
            public void onSuccess(ArrayList<EnergyRankBean> result) {
                Toast.makeText(this, "Success", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onError(String errorCode, String errorMessage) {
                Toast.makeText(this, "Failed", Toast.LENGTH_SHORT).show();
            }
        });

Get today’s sub-energy consumption percentage

Interface Description

Get the ranking of today’s energy consumption by percentage for all areas of the project to which you belong

TuyaCommercialLightingEnergy.getLightingEnergy().requestEnergySubentryPreview(
  long projectId,
  int targetType,
  long time, 
  ITuyaResultCallback<ArrayList<EnergyRankBean>> listener);

Parameter Description

parameter name type required description
projectId long true Query the target project id
targetType int true 1 for day, 2:month, 3:year
time long false The start time of the time range

Sample code

 TuyaCommercialLightingEnergy.getLightingEnergy().requestEnergySubentryPreview(1000, 1, 1623826206000, new ITuyaResultCallback< ArrayList<EnergyRankBean>>() {
            @Override
            public void onSuccess(ArrayList<EnergyRankBean> result) {
                Toast.makeText(this, "Get Success", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onError(String errorCode, String errorMessage) {
                Toast.makeText(this, "Failed to get", Toast.LENGTH_SHORT).show();
            }
        });

Get the chart data for each sub-category of energy consumption

Interface description

Get the graphical data of all energy consumption of the current project by sub-item, you can distinguish the time dimension of year, month and day

TuyaCommercialLightingEnergy.getLightingEnergy().requestEnergySubentryDetail(
  long projectId,
  int targetType,
  long time,
  int purposeCode, 
  ITuyaResultCallback<EnergySubentryBean> listener);

Parameter Description

parameter name type required description
projectId long true Query the target project id
targetType int true 1 for day, 2:month, 3:year
time long false The start time of the time range
purposeCode int true null or 0 or a level of equipment purpose code. null or 0 will return the data of all energy consumption sub-items (purpose); otherwise return the data of the specified energy consumption sub-item

Sample code

 TuyaCommercialLightingEnergy.getLightingEnergy().requestEnergySubentryDetail(10000, 1, 1623826206000, 1, new ITuyaResultCallback< EnergySubentryBean>() {
            @Override
            public void onSuccess(EnergySubentryBean result) {
                Toast.makeText(this, "Success in getting", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onError(String errorCode, String errorMessage) {
                Toast.makeText(this, "Failed to get", Toast.LENGTH_SHORT).show();
            }
        });

Query the number of energy consuming devices

Interface Description

Query the number of devices with energy consumption statistics under the current project

TuyaCommercialLightingEnergy.getLightingEnergy().requestEnergyReportDeviceSize(
  long projectId,
  ITuyaResultCallback<Integer> listener);

Parameter description

parameter name type required description
projectId long true Query the target project id

Sample Code

  TuyaCommercialLightingEnergy.getLightingEnergy().requestEnergyReportDeviceSize(10000, new ITuyaResultCallback<Integer>() {
            @Override
            public void onSuccess(Integer result) {
                Toast.makeText(this, "Get Success", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onError(String errorCode, String errorMessage) {
                Toast.makeText(this, "Failed to get", Toast.LENGTH_SHORT).show();
            }
        });

Get a list of itemized energy uses

Interface Description

Get the list of sub energy uses that exist under the selected area

TuyaCommercialLightingEnergy.getLightingEnergy().requestEnergyReportPurposes(
  long projectId,
  String areaIds,
  ITuyaResultCallback<ArrayList<EnergyPurposeBean>> listener);

Parameter Description

Parameter Name Type Required Description
projectId long true Query the target project id
areaIds String true Comma-separated area IDs, empty string means all

Sample code

 TuyaCommercialLightingEnergy.getLightingEnergy().requestEnergyReportPurposes(10000, "123,456", new ITuyaResultCallback<ArrayList< EnergyPurposeBean>>() {
            @Override
            public void onSuccess(ArrayList<EnergyPurposeBean> result) {
                Toast.makeText(this, "Get Success", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onError(String errorCode, String errorMessage) {
                Toast.makeText(this, "Failed to get", Toast.LENGTH_SHORT).show();
            }
        });

Query the list of energy consumption devices

Interface Description

Query the list of energy consumption data based on filter criteria

TuyaCommercialLightingEnergy.getLightingEnergy().requestEnergyReportDevices(
  long projectId, 
  long startTime,
  long endTime, 
  String areaIds, 
  String purposeCodes, 
  int pageNo, 
  int pageSize, 
  ITuyaResultCallback<EnergyReportDeviceBean> listener);

Parameter Description

parameter name type required description
projectId long true Query the target project id
startTime long true startTime
endTime long true The end time, specified to the last millisecond of the day
areaIds String true Comma-separated area IDs, empty string means all
purposeCodes String true The itemized energy code (,separated), the empty string means all the itemized energy
pageNo int false The number of pages to be paged, starting from 1.
pageSize int false Number of pages per page
Sample code
 TuyaCommercialLightingEnergy.getLightingEnergy().requestEnergyReportDevices(10000, 1623826106000, 1623826206000, "123", "123", 1, 10, new ITuyaResultCallback<EnergyReportDeviceBean>() {
            @Override
            public void onSuccess(EnergyReportDeviceBean result) {
                Toast.makeText(this, "Get Success", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onError(String errorCode, String errorMessage) {
                Toast.makeText(this, "Failed to get", Toast.LENGTH_SHORT).show();
            }
        });

Get energy consumption data overview

Interface description

Get energy consumption data for selected conditions (total energy consumption, energy consumption same-loop ratio, energy consumption graph data)

TuyaCommercialLightingEnergy.getLightingEnergy().requestEnergyAreaDetail(
  long projectId, 
  int targetType, 
  long startTime, 
  long endTime, 
  long areaId, 
  ITuyaResultCallback<EnergyAreaDetailBean> listener);

Parameter Description

parameter name type required description
projectId long true Query the target project id
targetType int false 1 for day, 2:month, 3:year
startTime long true start time
endTime long true The end time, specified to the last millisecond of the day
areaId long false Area ID, -1 for all

Sample code

 TuyaCommercialLightingEnergy.getLightingEnergy().requestEnergyAreaDetail(10000, 1, 1623826106000, 1623826206000, 123, new ITuyaResultCallback<EnergyAreaDetailBean>() {
            @Override
            public void onSuccess(EnergyAreaDetailBean result) {
                Toast.makeText(this, "Get Success", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void onError(String errorCode, String errorMessage) {
                Toast.makeText(this, "Failed to get", Toast.LENGTH_SHORT).show();
            }
        });