ElectricalEnergyMeasurement Cluster

Cluster ID: 0x0091  |  Endpoint: Typically on an electrical device endpoint (e.g. smart plug, energy meter, EV charger)

ElectricalEnergyMeasurement is responsible for recording the cumulative energy consumption (or output) of a device over time. Unlike ElectricalPowerMeasurement (0x0090) which measures instantaneous power, this Cluster focuses on "how much total energy has been used" and "how much energy was used during this period". Both typically coexist on the same Endpoint — the former is like a speedometer, the latter like an odometer.

Energy Unit: Milliwatt-hours (mWh)

All energy values are in mWh (milliwatt-hours), with type int64. A device returning 12345678 represents 12,345.678 Wh, i.e. 12.35 kWh. Unit conversion is required for display: divide by 1000 to get Wh, divide again by 1000 to get kWh.

Cumulative vs Periodic

This Cluster has two metering modes, determined by Features:
Cumulative: Total energy accumulated from a starting point, similar to a utility meter reading — it only increases (unless reset).
Periodic: Energy consumed within each measurement period, reset to zero at the end of each period — ideal for tracking "how much energy was used in the past hour."

Data Structures

ElectricalEnergyMeasurement uses two core Structs to carry data. Understanding these two structures is fundamental to reading the entire Cluster.

EnergyMeasurementStruct (Energy Measurement Data)

Every energy reading is represented by this structure. It contains the energy value and the corresponding time range.

Field Type Required Description
Energy int64 Yes Energy value in mWh (milliwatt-hours). Only increases in cumulative mode; resets each period in periodic mode
StartTimestamp epoch_s No Start UTC time of the measurement interval (second-precision Unix timestamp)
EndTimestamp epoch_s No End UTC time of the measurement interval (i.e. the most recent update time)
StartSystime systime_ms No Start system time of the measurement interval (milliseconds, device-local monotonic clock)
EndSystime systime_ms No End system time of the measurement interval (milliseconds)
Timestamp vs Systime

Time fields come in two flavors: Timestamp is UTC wall-clock time (requires the device to have synced via NTP), while Systime is a monotonically increasing clock since device boot (independent of network, but resets on reboot). The device provides at least one set; if both are available, prefer Timestamp.

CumulativeEnergyResetStruct (Cumulative Reset Information)

Records the time when the cumulative energy value was last reset. Used to determine the starting point of the current cumulative reading.

Field Type Description
ImportedResetTimestamp epoch_s UTC time when the import-side cumulative value was last reset
ExportedResetTimestamp epoch_s UTC time when the export-side cumulative value was last reset
ImportedResetSystime systime_ms System time when the import-side cumulative value was last reset
ExportedResetSystime systime_ms System time when the export-side cumulative value was last reset

Attributes

ElectricalEnergyMeasurement has 6 application-level attributes. Click an attribute ID to jump to its detailed description.

ID Name Type Required Feature Description
0x0000 Accuracy MeasurementAccuracyStruct None (Mandatory) Measurement accuracy description
0x0001 CumulativeEnergyImported EnergyMeasurementStruct IMPE & CUME Cumulative imported energy (consumption)
0x0002 CumulativeEnergyExported EnergyMeasurementStruct EXPE & CUME Cumulative exported energy (generation)
0x0003 PeriodicEnergyImported EnergyMeasurementStruct IMPE & PERE Current period imported energy
0x0004 PeriodicEnergyExported EnergyMeasurementStruct EXPE & PERE Current period exported energy
0x0005 CumulativeEnergyReset CumulativeEnergyResetStruct CUME Cumulative value reset time information

Accuracy (Measurement Accuracy)

Describes the measurement accuracy and range of this energy metering device. Uses the MeasurementAccuracyStruct structure, containing the measurement type (fixed to ElectricalEnergy), range limits, and accuracy descriptions for different intervals. This is the only mandatory attribute — all devices implementing this Cluster must report it.

  • Type: MeasurementAccuracyStruct
  • Access: Read-only
  • Required: Yes

CumulativeEnergyImported (Cumulative Imported Energy)

The total energy imported (consumed) by the device from the grid since metering started (or last reset). This is the everyday "total energy consumption," similar to a household utility meter reading. The value only increases, unless reset to zero.

  • Type: EnergyMeasurementStruct, Nullable
  • Required Features: IMPE (ImportedEnergy) + CUME (CumulativeEnergy)
  • Conversion: energy / 1000 = Wh, energy / 1000000 = kWh

CumulativeEnergyExported (Cumulative Exported Energy)

The cumulative total energy exported (fed back) by the device to the grid. Applicable to solar inverters, energy storage systems, and other devices capable of feeding power back to the grid. Ordinary household appliances do not report this attribute.

  • Type: EnergyMeasurementStruct, Nullable
  • Required Features: EXPE (ExportedEnergy) + CUME (CumulativeEnergy)

PeriodicEnergyImported (Periodic Imported Energy)

The energy imported (consumed) by the device within the current measurement period. Automatically resets at the end of each period. Ideal for tracking "how much energy was used in the past hour" or "today's usage." The period length is determined by the device implementation and can be calculated from StartTimestamp / EndTimestamp.

  • Type: EnergyMeasurementStruct, Nullable
  • Required Features: IMPE (ImportedEnergy) + PERE (PeriodicEnergy)

PeriodicEnergyExported (Periodic Exported Energy)

The energy exported (fed back) by the device to the grid within the current measurement period. Symmetric to PeriodicEnergyImported, used by devices with generation capability to track energy output per period.

  • Type: EnergyMeasurementStruct, Nullable
  • Required Features: EXPE (ExportedEnergy) + PERE (PeriodicEnergy)

CumulativeEnergyReset (Cumulative Reset Information)

Records when the cumulative energy value was last reset. Through this attribute you can determine when CumulativeEnergyImported / CumulativeEnergyExported started accumulating. If the device has never been reset, this attribute is null.

  • Type: CumulativeEnergyResetStruct, Nullable
  • Required Features: CUME (CumulativeEnergy)

Events

ElectricalEnergyMeasurement has no commands (read-only Cluster), but defines two important events. Devices proactively notify the app of energy data updates through events, which is more efficient than polling attributes on a timer — especially useful for scenarios that need to track energy consumption changes in real time.

ID Name Priority Required Feature Description
0x00 CumulativeEnergyMeasured INFO CUME Cumulative energy update
0x01 PeriodicEnergyMeasured INFO PERE Periodic energy update

CumulativeEnergyMeasured (Cumulative Energy Update Event)

Triggered when the device's cumulative energy value changes. The event data contains the latest cumulative imported and/or exported energy.

FieldTypeDescription
EnergyImported EnergyMeasurementStruct Latest cumulative imported energy (optional, depends on IMPE feature)
EnergyExported EnergyMeasurementStruct Latest cumulative exported energy (optional, depends on EXPE feature)

PeriodicEnergyMeasured (Periodic Energy Update Event)

Triggered at the end of each measurement period. The event data contains the imported and/or exported energy for that period. Ideal for apps to append data to historical records upon receiving this event, building energy consumption charts.

FieldTypeDescription
EnergyImported EnergyMeasurementStruct Imported energy for this period (optional, depends on IMPE feature)
EnergyExported EnergyMeasurementStruct Exported energy for this period (optional, depends on EXPE feature)

Feature Bitmap

ElectricalEnergyMeasurement declares the device's metering capabilities through FeatureMap (0xFFFC). The four Features combine in pairs to determine which attributes and events the device can provide:

Bit 0
IMPE (ImportedEnergy) Supports measuring imported energy (consumption) — the vast majority of devices have this feature
Bit 1
EXPE (ExportedEnergy) Supports measuring exported energy (generation/feed-back) — used by solar and energy storage devices
Bit 2
CUME (CumulativeEnergy) Supports cumulative metering — provides total energy from the starting point to the present
Bit 3
PERE (PeriodicEnergy) Supports periodic metering — provides energy consumption within each measurement period
Feature Combination Rules

A device must support at least one of IMPE or EXPE (it must measure energy in at least one direction), and at least one of CUME or PERE (it must have at least one metering mode). A typical smart plug usually only has IMPE + CUME (Bit 0 + Bit 2 = FeatureMap = 5), while a solar inverter may have all four enabled (FeatureMap = 15).

Relationship with ElectricalPowerMeasurement

Matter splits electrical measurement into two Clusters, each serving a distinct role:

ElectricalPowerMeasurement(0x0090) ElectricalEnergyMeasurement(0x0091)
What it measures Instantaneous power (Power) Accumulated energy (Energy)
Unit mW (milliwatts) mWh (milliwatt-hours)
Analogy A car's speedometer -- how fast right now A car's odometer -- total distance traveled
Typical reading "Current power 150W" "This month's consumption 45.3 kWh"
Data access Read attributes (real-time values) Subscribe to events (cumulative/periodic updates)

Both Clusters typically coexist on the same Endpoint. The app UI can simultaneously display real-time power (from 0x0090) and cumulative energy consumption (from 0x0091); the former is suited for real-time monitoring, the latter for consumption statistics and cost calculation.

Example Data

Read result of the ElectricalEnergyMeasurement Cluster for a smart plug supporting IMPE + CUME + PERE features:

{
  // --- ElectricalEnergyMeasurement Cluster(Endpoint 1)---

  // --- Measurement Accuracy ---
  "0x0000": {                    // Accuracy(MeasurementAccuracyStruct)
    "measurementType": 1,        // ElectricalEnergy
    "measured": true,
    "minMeasuredValue": 0,
    "maxMeasuredValue": 100000000000,  // 100,000 kWh
    "accuracyRanges": [{
      "rangeMin": 0,
      "rangeMax": 100000000000,
      "fixedMax": 5000           // Maximum fixed error 5000 mWh = 5 Wh
    }]
  },

  // --- Cumulative Energy (requires IMPE + CUME features) ---
  "0x0001": {                    // CumulativeEnergyImported
    "energy": 12345678,          // 12,345,678 mWh = 12,345.678 Wh ≈ 12.35 kWh
    "startTimestamp": 1700000000,// 2023-11-14T22:13:20Z (metering start time)
    "endTimestamp": 1700086400   // 2023-11-15T22:13:20Z (latest update time)
  },

  // --- Periodic Energy (requires IMPE + PERE features) ---
  "0x0003": {                    // PeriodicEnergyImported
    "energy": 543210,            // 543,210 mWh = 543.21 Wh ≈ 0.54 kWh (this period consumption)
    "startTimestamp": 1700082800,// Period start time
    "endTimestamp": 1700086400   // Period end time (1-hour period)
  },

  // --- Cumulative Reset Info (requires CUME feature) ---
  "0x0005": {                    // CumulativeEnergyReset
    "importedResetTimestamp": 1700000000  // Time of last cumulative value reset
  }
}

CumulativeEnergyMeasured event data example:

{
  // CumulativeEnergyMeasured Event — cumulative energy update notification
  "eventId": "0x00",
  "priority": "INFO",
  "data": {
    "energyImported": {
      "energy": 12345678,          // 12,345.678 Wh
      "startTimestamp": 1700000000,
      "endTimestamp": 1700086400
    }
    // energyExported omitted (this device does not support reverse output)
  }
}
Unit Conversion Code Reference

Key logic for handling energy values returned by the device:

{`// Device returns energy = 12345678 (mWh)
val rawEnergy: Long? = 12345678    // Nullable, may be null
val wattHours = rawEnergy?.let { it / 1000.0 }     // → 12,345.678 Wh
val kilowattHours = rawEnergy?.let { it / 1_000_000.0 }  // → 12.346 kWh

// Handle null + choose appropriate unit for display
val display = kilowattHours?.let {
    if (it < 1.0) String.format("%.1f Wh", it * 1000)  // Show Wh if less than 1 kWh
    else String.format("%.2f kWh", it)
} ?: "--"`}

Common Scenarios

Scenario 1: Smart Plug Energy Statistics Dashboard
  1. Check FeatureMap (0xFFFC) to confirm the device's supported metering modes (CUME / PERE / IMPE / EXPE)
  2. Subscribe to the CumulativeEnergyMeasured (0x00) event to track cumulative consumption changes in real time
  3. Read CumulativeEnergyImported (0x0001) to get the current total consumption; divide by 1,000,000 to convert to kWh
  4. If PERE is supported, also subscribe to the PeriodicEnergyMeasured (0x01) event and use each period's data to plot an energy consumption chart
  5. Calculate cost using local electricity rates: cost = kWh x rate (currency/kWh)
  6. Combine with ElectricalPowerMeasurement (0x0090) to simultaneously display "Current Power" and "Cumulative Consumption" in the UI
Scenario 2: Bidirectional Energy Monitoring for Solar + Storage Systems
  1. Confirm the device's FeatureMap includes IMPE + EXPE (bidirectional metering) + CUME + PERE (both modes)
  2. Read CumulativeEnergyImported (0x0001) to get the total energy purchased from the grid
  3. Read CumulativeEnergyExported (0x0002) to get the total energy fed back to the grid
  4. Calculate net consumption: net = Imported - Exported; a negative value indicates the device is a net generator
  5. Subscribe to the PeriodicEnergyMeasured (0x01) event to track per-period stats: "how much energy was generated and consumed this hour"
  6. Read CumulativeEnergyReset (0x0005) to confirm the starting time of cumulative data, avoiding confusion across devices or periods