Skip to content

Commit 0d2ffbb

Browse files
authored
Feature/electrical energy & power measurement clusters (#31518)
* 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
1 parent a77e01c commit 0d2ffbb

File tree

93 files changed

+18092
-1659
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+18092
-1659
lines changed

.github/workflows/tests.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ jobs:
118118
src/app/zap-templates/zcl/data-model/chip/diagnostic-logs-cluster.xml \
119119
src/app/zap-templates/zcl/data-model/chip/dishwasher-alarm-cluster.xml \
120120
src/app/zap-templates/zcl/data-model/chip/dishwasher-mode-cluster.xml \
121+
src/app/zap-templates/zcl/data-model/chip/measurement-and-sensing.xml \
121122
src/app/zap-templates/zcl/data-model/chip/microwave-oven-mode-cluster.xml \
122123
src/app/zap-templates/zcl/data-model/chip/microwave-oven-control-cluster.xml \
123124
src/app/zap-templates/zcl/data-model/chip/door-lock-cluster.xml \
@@ -194,6 +195,8 @@ jobs:
194195
src/app/zap-templates/zcl/data-model/draft/onoff-switch-configuration-cluster.xml \
195196
src/app/zap-templates/zcl/data-model/chip/resource-monitoring-cluster.xml \
196197
src/app/zap-templates/zcl/data-model/chip/sample-mei-cluster.xml \
198+
src/app/zap-templates/zcl/data-model/chip/electrical-energy-measurement-cluster.xml \
199+
src/app/zap-templates/zcl/data-model/chip/electrical-power-measurement-cluster.xml \
197200
"
198201
- name: Build Apps
199202
run: |

docs/clusters.md

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ Generally regenerate using one of:
7777
| 114 | 0x72 | ActivatedCarbonFilterMonitoring |
7878
| 128 | 0x80 | BooleanStateConfiguration |
7979
| 129 | 0x81 | ValveConfigurationAndControl |
80+
| 144 | 0x90 | ElectricalPowerMeasurement |
8081
| 145 | 0x91 | ElectricalEnergyMeasurement |
8182
| 150 | 0x96 | DemandResponseLoadControl |
8283
| 151 | 0x97 | Messages |

examples/all-clusters-app/all-clusters-common/all-clusters-app.matter

+145-2
Original file line numberDiff line numberDiff line change
@@ -3859,6 +3859,111 @@ provisional cluster ValveConfigurationAndControl = 129 {
38593859
command Close(): DefaultSuccess = 1;
38603860
}
38613861

3862+
/** This cluster provides a mechanism for querying data about electrical power as measured by the server. */
3863+
provisional cluster ElectricalPowerMeasurement = 144 {
3864+
revision 1;
3865+
3866+
enum MeasurementTypeEnum : enum16 {
3867+
kUnspecified = 0;
3868+
kVoltage = 1;
3869+
kActiveCurrent = 2;
3870+
kReactiveCurrent = 3;
3871+
kApparentCurrent = 4;
3872+
kActivePower = 5;
3873+
kReactivePower = 6;
3874+
kApparentPower = 7;
3875+
kRMSVoltage = 8;
3876+
kRMSCurrent = 9;
3877+
kRMSPower = 10;
3878+
kFrequency = 11;
3879+
kPowerFactor = 12;
3880+
kNeutralCurrent = 13;
3881+
kElectricalEnergy = 14;
3882+
}
3883+
3884+
enum PowerModeEnum : enum8 {
3885+
kUnknown = 0;
3886+
kDC = 1;
3887+
kAC = 2;
3888+
}
3889+
3890+
bitmap Feature : bitmap32 {
3891+
kDirectCurrent = 0x1;
3892+
kAlternatingCurrent = 0x2;
3893+
kPolyphasePower = 0x4;
3894+
kHarmonics = 0x8;
3895+
kPowerQuality = 0x10;
3896+
}
3897+
3898+
struct MeasurementAccuracyRangeStruct {
3899+
int64s rangeMin = 0;
3900+
int64s rangeMax = 1;
3901+
optional percent100ths percentMax = 2;
3902+
optional percent100ths percentMin = 3;
3903+
optional percent100ths percentTypical = 4;
3904+
optional int64u fixedMax = 5;
3905+
optional int64u fixedMin = 6;
3906+
optional int64u fixedTypical = 7;
3907+
}
3908+
3909+
struct MeasurementAccuracyStruct {
3910+
MeasurementTypeEnum measurementType = 0;
3911+
boolean measured = 1;
3912+
int64s minMeasuredValue = 2;
3913+
int64s maxMeasuredValue = 3;
3914+
MeasurementAccuracyRangeStruct accuracyRanges[] = 4;
3915+
}
3916+
3917+
struct HarmonicMeasurementStruct {
3918+
int8u order = 0;
3919+
nullable int64s measurement = 1;
3920+
}
3921+
3922+
struct MeasurementRangeStruct {
3923+
MeasurementTypeEnum measurementType = 0;
3924+
int64s min = 1;
3925+
int64s max = 2;
3926+
optional epoch_s startTimestamp = 3;
3927+
optional epoch_s endTimestamp = 4;
3928+
optional epoch_s minTimestamp = 5;
3929+
optional epoch_s maxTimestamp = 6;
3930+
optional systime_ms startSystime = 7;
3931+
optional systime_ms endSystime = 8;
3932+
optional systime_ms minSystime = 9;
3933+
optional systime_ms maxSystime = 10;
3934+
}
3935+
3936+
info event MeasurementPeriodRanges = 0 {
3937+
MeasurementRangeStruct ranges[] = 0;
3938+
}
3939+
3940+
readonly attribute PowerModeEnum powerMode = 0;
3941+
readonly attribute int8u numberOfMeasurementTypes = 1;
3942+
readonly attribute MeasurementAccuracyStruct accuracy[] = 2;
3943+
readonly attribute optional MeasurementRangeStruct ranges[] = 3;
3944+
readonly attribute optional nullable voltage_mv voltage = 4;
3945+
readonly attribute optional nullable amperage_ma activeCurrent = 5;
3946+
readonly attribute optional nullable amperage_ma reactiveCurrent = 6;
3947+
readonly attribute optional nullable amperage_ma apparentCurrent = 7;
3948+
readonly attribute nullable power_mw activePower = 8;
3949+
readonly attribute optional nullable power_mw reactivePower = 9;
3950+
readonly attribute optional nullable power_mw apparentPower = 10;
3951+
readonly attribute optional nullable voltage_mv RMSVoltage = 11;
3952+
readonly attribute optional nullable amperage_ma RMSCurrent = 12;
3953+
readonly attribute optional nullable power_mw RMSPower = 13;
3954+
readonly attribute optional nullable int64s frequency = 14;
3955+
readonly attribute optional nullable HarmonicMeasurementStruct harmonicCurrents[] = 15;
3956+
readonly attribute optional nullable HarmonicMeasurementStruct harmonicPhases[] = 16;
3957+
readonly attribute optional nullable int64s powerFactor = 17;
3958+
readonly attribute optional nullable amperage_ma neutralCurrent = 18;
3959+
readonly attribute command_id generatedCommandList[] = 65528;
3960+
readonly attribute command_id acceptedCommandList[] = 65529;
3961+
readonly attribute event_id eventList[] = 65530;
3962+
readonly attribute attrib_id attributeList[] = 65531;
3963+
readonly attribute bitmap32 featureMap = 65532;
3964+
readonly attribute int16u clusterRevision = 65533;
3965+
}
3966+
38623967
/** This cluster provides a mechanism for querying data about the electrical energy imported or provided by the server. */
38633968
provisional cluster ElectricalEnergyMeasurement = 145 {
38643969
revision 1;
@@ -3907,8 +4012,15 @@ provisional cluster ElectricalEnergyMeasurement = 145 {
39074012
MeasurementAccuracyRangeStruct accuracyRanges[] = 4;
39084013
}
39094014

4015+
struct CumulativeEnergyResetStruct {
4016+
optional nullable epoch_s importedResetTimestamp = 0;
4017+
optional nullable epoch_s exportedResetTimestamp = 1;
4018+
optional nullable systime_ms importedResetSystime = 2;
4019+
optional nullable systime_ms exportedResetSystime = 3;
4020+
}
4021+
39104022
struct EnergyMeasurementStruct {
3911-
int64s energy = 0;
4023+
energy_mwh energy = 0;
39124024
optional epoch_s startTimestamp = 1;
39134025
optional epoch_s endTimestamp = 2;
39144026
optional systime_ms startSystime = 3;
@@ -3930,6 +4042,7 @@ provisional cluster ElectricalEnergyMeasurement = 145 {
39304042
readonly attribute optional nullable EnergyMeasurementStruct cumulativeEnergyExported = 2;
39314043
readonly attribute optional nullable EnergyMeasurementStruct periodicEnergyImported = 3;
39324044
readonly attribute optional nullable EnergyMeasurementStruct periodicEnergyExported = 4;
4045+
readonly attribute optional nullable CumulativeEnergyResetStruct cumulativeEnergyReset = 5;
39334046
readonly attribute command_id generatedCommandList[] = 65528;
39344047
readonly attribute command_id acceptedCommandList[] = 65529;
39354048
readonly attribute event_id eventList[] = 65530;
@@ -8083,6 +8196,35 @@ endpoint 1 {
80838196
handle command Close;
80848197
}
80858198

8199+
server cluster ElectricalPowerMeasurement {
8200+
emits event MeasurementPeriodRanges;
8201+
callback attribute powerMode;
8202+
callback attribute numberOfMeasurementTypes;
8203+
callback attribute accuracy;
8204+
callback attribute ranges;
8205+
callback attribute voltage;
8206+
callback attribute activeCurrent;
8207+
callback attribute reactiveCurrent;
8208+
callback attribute apparentCurrent;
8209+
callback attribute activePower;
8210+
callback attribute reactivePower;
8211+
callback attribute apparentPower;
8212+
callback attribute RMSVoltage;
8213+
callback attribute RMSCurrent;
8214+
callback attribute RMSPower;
8215+
callback attribute frequency;
8216+
callback attribute harmonicCurrents;
8217+
callback attribute harmonicPhases;
8218+
callback attribute powerFactor;
8219+
callback attribute neutralCurrent;
8220+
callback attribute generatedCommandList;
8221+
callback attribute acceptedCommandList;
8222+
callback attribute eventList;
8223+
callback attribute attributeList;
8224+
callback attribute featureMap;
8225+
ram attribute clusterRevision default = 1;
8226+
}
8227+
80868228
server cluster ElectricalEnergyMeasurement {
80878229
emits event CumulativeEnergyMeasured;
80888230
emits event PeriodicEnergyMeasured;
@@ -8091,11 +8233,12 @@ endpoint 1 {
80918233
callback attribute cumulativeEnergyExported;
80928234
callback attribute periodicEnergyImported;
80938235
callback attribute periodicEnergyExported;
8236+
callback attribute cumulativeEnergyReset;
80948237
callback attribute generatedCommandList;
80958238
callback attribute acceptedCommandList;
80968239
callback attribute eventList;
80978240
callback attribute attributeList;
8098-
ram attribute featureMap default = 0x000F;
8241+
callback attribute featureMap;
80998242
ram attribute clusterRevision default = 1;
81008243
}
81018244

0 commit comments

Comments
 (0)