Skip to content

Commit

Permalink
Add initial Electrical Power Measurement cluster implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
hasty committed Jan 18, 2024
1 parent 47f5298 commit dc8756b
Show file tree
Hide file tree
Showing 78 changed files with 108,442 additions and 141,011 deletions.
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 |
| 152 | 0x98 | DeviceEnergyManagement |
Expand Down
122 changes: 119 additions & 3 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -3843,6 +3843,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 @@ -3892,7 +3997,7 @@ provisional cluster ElectricalEnergyMeasurement = 145 {
}

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 Down Expand Up @@ -7737,9 +7842,20 @@ endpoint 1 {
handle command Close;
}

server cluster ElectricalPowerMeasurement {
callback attribute powerMode;
callback attribute numberOfMeasurementTypes;
callback attribute accuracy;
callback attribute activePower;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
callback attribute attributeList;
ram attribute featureMap default = 0;
ram attribute clusterRevision default = 1;
}

server cluster ElectricalEnergyMeasurement {
emits event CumulativeEnergyMeasured;
emits event PeriodicEnergyMeasured;
callback attribute accuracy;
callback attribute cumulativeEnergyImported;
callback attribute cumulativeEnergyExported;
Expand Down
201 changes: 178 additions & 23 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -6575,11 +6575,11 @@
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
},
{
"name": "RemoveAllScenesResponse",
"code": 3,
"mfgCode": null,
"mfgCode": null,
"source": "server",
"isIncoming": 0,
"isEnabled": 1
Expand Down Expand Up @@ -7139,13 +7139,13 @@
"reportableChange": 0
}
]
},
{
},
{
"name": "On/off Switch Configuration",
"code": 7,
"mfgCode": null,
"mfgCode": null,
"define": "ON_OFF_SWITCH_CONFIGURATION_CLUSTER",
"side": "server",
"side": "server",
"enabled": 1,
"apiMaturity": "deprecated",
"attributes": [
Expand Down Expand Up @@ -12445,6 +12445,177 @@
}
]
},
{
"name": "Electrical Power Measurement",
"code": 144,
"mfgCode": null,
"define": "ELECTRICAL_POWER_MEASUREMENT_CLUSTER",
"side": "server",
"enabled": 1,
"apiMaturity": "provisional",
"attributes": [
{
"name": "PowerMode",
"code": 0,
"mfgCode": null,
"side": "server",
"type": "PowerModeEnum",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "NumberOfMeasurementTypes",
"code": 1,
"mfgCode": null,
"side": "server",
"type": "int8u",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "Accuracy",
"code": 2,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "ActivePower",
"code": 8,
"mfgCode": null,
"side": "server",
"type": "power_mw",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "GeneratedCommandList",
"code": 65528,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "AcceptedCommandList",
"code": 65529,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "EventList",
"code": 65530,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "AttributeList",
"code": 65531,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "FeatureMap",
"code": 65532,
"mfgCode": null,
"side": "server",
"type": "bitmap32",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "ClusterRevision",
"code": 65533,
"mfgCode": null,
"side": "server",
"type": "int16u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "1",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
}
]
},
{
"name": "Electrical Energy Measurement",
"code": 145,
Expand Down Expand Up @@ -12630,22 +12801,6 @@
"maxInterval": 65534,
"reportableChange": 0
}
],
"events": [
{
"name": "CumulativeEnergyMeasured",
"code": 0,
"mfgCode": null,
"side": "server",
"included": 1
},
{
"name": "PeriodicEnergyMeasured",
"code": 1,
"mfgCode": null,
"side": "server",
"included": 1
}
]
},
{
Expand Down
1 change: 1 addition & 0 deletions examples/all-clusters-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/laundry-washer-controls-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/laundry-dryer-controls-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/electrical-energy-measurement-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/electrical-power-measurement-server"
)


Expand Down
Loading

0 comments on commit dc8756b

Please sign in to comment.