Skip to content

How to call ElectricalEnergyMeasurementCluster::GetCumulativeEnergyImported? (CON-1950) #1680

@olavt

Description

@olavt

I used to have this code working:

// Get the previous measurement
MeasurementData* previousMeasurement = ElectricalEnergyMeasurement::MeasurementDataForEndpoint(GetEndpointId());

then I used it to get the timestamps for the last measurement:

energyImported.startTimestamp.ClearValue();
energyImported.startSystime.ClearValue();
if (previousMeasurement->cumulativeImported.HasValue())
{
    energyImported.startTimestamp = previousMeasurement->cumulativeImported.Value().endTimestamp;
    energyImported.startSystime   = previousMeasurement->cumulativeImported.Value().endSystime;
}

The problem is that ElectricalEnergyMeasurement::MeasurementDataForEndpoint doesn't seem to exist anymore.

But, I found this function (in app/clusters/electrical-energy-measurement-server/ElectricalEnergyMeasurementCluster.cpp):

CHIP_ERROR ElectricalEnergyMeasurementCluster::GetCumulativeEnergyImported(Optional<EnergyMeasurementStruct> & outValue) const

But, I don't fully understand how to call it from code like the all-device-types-app electrical-measurement.cpp.

How would such code look like?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions