Skip to content

Commit

Permalink
Feature/electrical energy & power measurement clusters (#31518)
Browse files Browse the repository at this point in the history
* Hoist shared enums and bitmaps into detail namespace

* Regenerate

* Add electrical measurement clusters

* Add NumberOfMeasurements attribute

* Bump to latest spec

* Bump ZAP version

* Remove Electrical Measurement cluster

* Add initial Electrical Power Measurement cluster implementation

* Revert "Remove Electrical Measurement cluster"

This reverts commit 47f5298.

* Fix incorrect min/max values on energy attributes

* Formatting electrical-power-measurement-server

* Regen after restoring deprecated electrical measurement cluster

* Re-add inexplicably important blank line to zap_execution.py

* De-alphabetize list of files to avoid breaking GH action

* Semi-realphabetize?

* Restore strangely dropped events

* Better BitMask handling

* Change min/max on electrical measurements to be decimal instead of hex

* Rename meas-and-sense to measurement-and-sensing.xml

* Remove seemingly superfluous attribute requirements on Descriptor cluster on Electrical Measurement

* Updates to electrical-power-measurement-server based on comments

* Remove defaults from MeasurementAccuracyRangeStruct to match spec update

* Restore side="server" to events

* Move common enums and bitmaps to detail:: instead of detail::Enums and detail::Bitmaps; remove superfluous using statement

* Assign ID to Electrical Sensor device type

* Removed EPM and EEM from Root Node Device

* Restyled formatting is different than clang-format

* Re-add FeatureMap to attributeAccessInterfaceAttributes for EEM and EPM

* Regen after merge

* Lock client on Electrical Sensor device type

* Remove unneeded using statement now that Enums are in detail::

* Check for null iterators and error

* Switch to ResourceExhausted from CHIP_ERROR_INTERNAL

* Add stub for EPM cluster

* Fixes for Python tests

* Correct name for Ember init callback

* Formatting

* Sync optional attributes list with .zap file for EPM

* Add missing features to EPM stub

* Revert FeatureMap in attributeAccessInterfaceAttributes

* Allow FeatureMap in EEM constructor; add all-clusters-app EEM stub

* Forgot zcl-with-test-extensions

* Unregister EEM attribute access in destructor

* Remove redundant returns to keep clang-tidy happy

* Add CumulativeEnergyResetStruct and CumulativeEnergyReset attribute to EEM

* Add optional CumulativeEnergyReset attribute to EEM
  • Loading branch information
hasty authored Feb 1, 2024
1 parent a77e01c commit 0d2ffbb
Show file tree
Hide file tree
Showing 93 changed files with 18,092 additions and 1,659 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ jobs:
src/app/zap-templates/zcl/data-model/chip/diagnostic-logs-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/dishwasher-alarm-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/dishwasher-mode-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/measurement-and-sensing.xml \
src/app/zap-templates/zcl/data-model/chip/microwave-oven-mode-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/microwave-oven-control-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/door-lock-cluster.xml \
Expand Down Expand Up @@ -194,6 +195,8 @@ jobs:
src/app/zap-templates/zcl/data-model/draft/onoff-switch-configuration-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/resource-monitoring-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/sample-mei-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/electrical-energy-measurement-cluster.xml \
src/app/zap-templates/zcl/data-model/chip/electrical-power-measurement-cluster.xml \
"
- name: Build Apps
run: |
Expand Down
1 change: 1 addition & 0 deletions docs/clusters.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ Generally regenerate using one of:
| 114 | 0x72 | ActivatedCarbonFilterMonitoring |
| 128 | 0x80 | BooleanStateConfiguration |
| 129 | 0x81 | ValveConfigurationAndControl |
| 144 | 0x90 | ElectricalPowerMeasurement |
| 145 | 0x91 | ElectricalEnergyMeasurement |
| 150 | 0x96 | DemandResponseLoadControl |
| 151 | 0x97 | Messages |
Expand Down
147 changes: 145 additions & 2 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -3859,6 +3859,111 @@ provisional cluster ValveConfigurationAndControl = 129 {
command Close(): DefaultSuccess = 1;
}

/** This cluster provides a mechanism for querying data about electrical power as measured by the server. */
provisional cluster ElectricalPowerMeasurement = 144 {
revision 1;

enum MeasurementTypeEnum : enum16 {
kUnspecified = 0;
kVoltage = 1;
kActiveCurrent = 2;
kReactiveCurrent = 3;
kApparentCurrent = 4;
kActivePower = 5;
kReactivePower = 6;
kApparentPower = 7;
kRMSVoltage = 8;
kRMSCurrent = 9;
kRMSPower = 10;
kFrequency = 11;
kPowerFactor = 12;
kNeutralCurrent = 13;
kElectricalEnergy = 14;
}

enum PowerModeEnum : enum8 {
kUnknown = 0;
kDC = 1;
kAC = 2;
}

bitmap Feature : bitmap32 {
kDirectCurrent = 0x1;
kAlternatingCurrent = 0x2;
kPolyphasePower = 0x4;
kHarmonics = 0x8;
kPowerQuality = 0x10;
}

struct MeasurementAccuracyRangeStruct {
int64s rangeMin = 0;
int64s rangeMax = 1;
optional percent100ths percentMax = 2;
optional percent100ths percentMin = 3;
optional percent100ths percentTypical = 4;
optional int64u fixedMax = 5;
optional int64u fixedMin = 6;
optional int64u fixedTypical = 7;
}

struct MeasurementAccuracyStruct {
MeasurementTypeEnum measurementType = 0;
boolean measured = 1;
int64s minMeasuredValue = 2;
int64s maxMeasuredValue = 3;
MeasurementAccuracyRangeStruct accuracyRanges[] = 4;
}

struct HarmonicMeasurementStruct {
int8u order = 0;
nullable int64s measurement = 1;
}

struct MeasurementRangeStruct {
MeasurementTypeEnum measurementType = 0;
int64s min = 1;
int64s max = 2;
optional epoch_s startTimestamp = 3;
optional epoch_s endTimestamp = 4;
optional epoch_s minTimestamp = 5;
optional epoch_s maxTimestamp = 6;
optional systime_ms startSystime = 7;
optional systime_ms endSystime = 8;
optional systime_ms minSystime = 9;
optional systime_ms maxSystime = 10;
}

info event MeasurementPeriodRanges = 0 {
MeasurementRangeStruct ranges[] = 0;
}

readonly attribute PowerModeEnum powerMode = 0;
readonly attribute int8u numberOfMeasurementTypes = 1;
readonly attribute MeasurementAccuracyStruct accuracy[] = 2;
readonly attribute optional MeasurementRangeStruct ranges[] = 3;
readonly attribute optional nullable voltage_mv voltage = 4;
readonly attribute optional nullable amperage_ma activeCurrent = 5;
readonly attribute optional nullable amperage_ma reactiveCurrent = 6;
readonly attribute optional nullable amperage_ma apparentCurrent = 7;
readonly attribute nullable power_mw activePower = 8;
readonly attribute optional nullable power_mw reactivePower = 9;
readonly attribute optional nullable power_mw apparentPower = 10;
readonly attribute optional nullable voltage_mv RMSVoltage = 11;
readonly attribute optional nullable amperage_ma RMSCurrent = 12;
readonly attribute optional nullable power_mw RMSPower = 13;
readonly attribute optional nullable int64s frequency = 14;
readonly attribute optional nullable HarmonicMeasurementStruct harmonicCurrents[] = 15;
readonly attribute optional nullable HarmonicMeasurementStruct harmonicPhases[] = 16;
readonly attribute optional nullable int64s powerFactor = 17;
readonly attribute optional nullable amperage_ma neutralCurrent = 18;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
readonly attribute attrib_id attributeList[] = 65531;
readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;
}

/** This cluster provides a mechanism for querying data about the electrical energy imported or provided by the server. */
provisional cluster ElectricalEnergyMeasurement = 145 {
revision 1;
Expand Down Expand Up @@ -3907,8 +4012,15 @@ provisional cluster ElectricalEnergyMeasurement = 145 {
MeasurementAccuracyRangeStruct accuracyRanges[] = 4;
}

struct CumulativeEnergyResetStruct {
optional nullable epoch_s importedResetTimestamp = 0;
optional nullable epoch_s exportedResetTimestamp = 1;
optional nullable systime_ms importedResetSystime = 2;
optional nullable systime_ms exportedResetSystime = 3;
}

struct EnergyMeasurementStruct {
int64s energy = 0;
energy_mwh energy = 0;
optional epoch_s startTimestamp = 1;
optional epoch_s endTimestamp = 2;
optional systime_ms startSystime = 3;
Expand All @@ -3930,6 +4042,7 @@ provisional cluster ElectricalEnergyMeasurement = 145 {
readonly attribute optional nullable EnergyMeasurementStruct cumulativeEnergyExported = 2;
readonly attribute optional nullable EnergyMeasurementStruct periodicEnergyImported = 3;
readonly attribute optional nullable EnergyMeasurementStruct periodicEnergyExported = 4;
readonly attribute optional nullable CumulativeEnergyResetStruct cumulativeEnergyReset = 5;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand Down Expand Up @@ -8083,6 +8196,35 @@ endpoint 1 {
handle command Close;
}

server cluster ElectricalPowerMeasurement {
emits event MeasurementPeriodRanges;
callback attribute powerMode;
callback attribute numberOfMeasurementTypes;
callback attribute accuracy;
callback attribute ranges;
callback attribute voltage;
callback attribute activeCurrent;
callback attribute reactiveCurrent;
callback attribute apparentCurrent;
callback attribute activePower;
callback attribute reactivePower;
callback attribute apparentPower;
callback attribute RMSVoltage;
callback attribute RMSCurrent;
callback attribute RMSPower;
callback attribute frequency;
callback attribute harmonicCurrents;
callback attribute harmonicPhases;
callback attribute powerFactor;
callback attribute neutralCurrent;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
callback attribute attributeList;
callback attribute featureMap;
ram attribute clusterRevision default = 1;
}

server cluster ElectricalEnergyMeasurement {
emits event CumulativeEnergyMeasured;
emits event PeriodicEnergyMeasured;
Expand All @@ -8091,11 +8233,12 @@ endpoint 1 {
callback attribute cumulativeEnergyExported;
callback attribute periodicEnergyImported;
callback attribute periodicEnergyExported;
callback attribute cumulativeEnergyReset;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
callback attribute attributeList;
ram attribute featureMap default = 0x000F;
callback attribute featureMap;
ram attribute clusterRevision default = 1;
}

Expand Down
Loading

0 comments on commit 0d2ffbb

Please sign in to comment.