Skip to content

Commit

Permalink
Feature/electrical energy measurement (project-chip#30389)
Browse files Browse the repository at this point in the history
* Added the xml for the electrical energy measurement cluster

* Added convienience functions for sending events

* Fixed weird whitespace

* ran codegen

* Add license server

* Remove chip namespace prefix because we are in the chip namespace already

* Restyle and use CHIP_ERROR_FORMAT

* Fix header as well

* Restyle

* Some changes from epoch_s to systime_ms

* Update the cluster to the latest version from the SPEC PR

* Zap regen

* Remove files that are not generated anymore by our xmls

* Mark struct type attributes as needing attributeAccessInterfaceAttributes

* Ran zap_convert_all.py

* zaq regen after zap convert

* make all clusters compile

* Fix domain

* Do not use PRIu64

* Fix esp32 compilation - add server cluster directory

* Start adding an attribute encoding interface - for now we write nulls

* Start adding some storage capability for the energy bits

* Also add attribute access interface for accuracy

* Also reserve space for dynamic endpoints. Note that accuracy setting is still missing

* Make reporting work when accuracy is changed

* Fix featuremap default

* XML updates based on review

* Zap regen all

* Update some copyrights

* Undo submodule change

* fix test

---------

Co-authored-by: Andrei Litvin <[email protected]>
Co-authored-by: Andrei Litvin <[email protected]>
  • Loading branch information
3 people authored Dec 11, 2023
1 parent d4595af commit 29ea755
Show file tree
Hide file tree
Showing 143 changed files with 9,558 additions and 494 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 | BooleanSensorConfiguration |
| 129 | 0x81 | ValveConfigurationAndControl |
| 145 | 0x91 | ElectricalEnergyMeasurement |
| 150 | 0x96 | DemandResponseLoadControl |
| 152 | 0x98 | DeviceEnergyManagement |
| 153 | 0x99 | EnergyEvse |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7583,5 +7583,6 @@
"endpointId": 4,
"networkId": 0
}
]
],
"log": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -6063,5 +6063,6 @@
"endpointId": 1,
"networkId": 0
}
]
],
"log": []
}
Original file line number Diff line number Diff line change
Expand Up @@ -3638,6 +3638,85 @@ cluster ActivatedCarbonFilterMonitoring = 114 {
command ResetCondition(): DefaultSuccess = 0;
}

/** This cluster provides a mechanism for querying data about the electrical energy imported or provided by the server. */
provisional cluster ElectricalEnergyMeasurement = 145 {
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;
}

bitmap Feature : bitmap32 {
kImportedEnergy = 0x1;
kExportedEnergy = 0x2;
kCumulativeEnergy = 0x4;
kPeriodicEnergy = 0x8;
}

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 EnergyMeasurementStruct {
int64s energy = 0;
optional epoch_s startTimestamp = 1;
optional epoch_s endTimestamp = 2;
optional systime_ms startSystime = 3;
optional systime_ms endSystime = 4;
}

info event CumulativeEnergyMeasured = 0 {
optional EnergyMeasurementStruct energyImported = 0;
optional EnergyMeasurementStruct energyExported = 1;
}

info event PeriodicEnergyMeasured = 1 {
optional EnergyMeasurementStruct energyImported = 0;
optional EnergyMeasurementStruct energyExported = 1;
}

readonly attribute MeasurementAccuracyStruct accuracy = 0;
readonly attribute optional nullable EnergyMeasurementStruct cumulativeEnergyImported = 1;
readonly attribute optional nullable EnergyMeasurementStruct cumulativeEnergyExported = 2;
readonly attribute optional nullable EnergyMeasurementStruct periodicEnergyImported = 3;
readonly attribute optional nullable EnergyMeasurementStruct periodicEnergyExported = 4;
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;
}

/** Provides an interface for controlling and adjusting automatic window coverings. */
cluster WindowCovering = 258 {
revision 5;
Expand Down Expand Up @@ -7046,6 +7125,22 @@ endpoint 1 {
handle command ResetCondition;
}

server cluster ElectricalEnergyMeasurement {
emits event CumulativeEnergyMeasured;
emits event PeriodicEnergyMeasured;
callback attribute accuracy;
callback attribute cumulativeEnergyImported;
callback attribute cumulativeEnergyExported;
callback attribute periodicEnergyImported;
callback attribute periodicEnergyExported;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
callback attribute attributeList;
ram attribute featureMap default = 0x000F;
ram attribute clusterRevision default = 1;
}

server cluster WindowCovering {
ram attribute type default = 0x08;
ram attribute physicalClosedLimitLift default = 0xFFFF;
Expand Down
221 changes: 220 additions & 1 deletion examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -11524,6 +11524,225 @@
}
]
},
{
"name": "Electrical Energy Measurement",
"code": 145,
"mfgCode": null,
"define": "ELECTRICAL_ENERGY_MEASUREMENT_CLUSTER",
"side": "server",
"enabled": 1,
"apiMaturity": "provisional",
"attributes": [
{
"name": "Measured",
"code": 0,
"mfgCode": null,
"side": "server",
"type": "boolean",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "false",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "Accuracy",
"code": 1,
"mfgCode": null,
"side": "server",
"type": "MeasurementAccuracyStruct",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "CumulativeEnergyImported",
"code": 2,
"mfgCode": null,
"side": "server",
"type": "EnergyMeasurementStruct",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "CumulativeEnergyExported",
"code": 3,
"mfgCode": null,
"side": "server",
"type": "EnergyMeasurementStruct",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "PeriodicEnergyImported",
"code": 4,
"mfgCode": null,
"side": "server",
"type": "EnergyMeasurementStruct",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "PeriodicEnergyExported",
"code": 5,
"mfgCode": null,
"side": "server",
"type": "EnergyMeasurementStruct",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": null,
"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": null,
"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": null,
"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": null,
"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": null,
"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": "0x000F",
"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
}
],
"events": [
{
"name": "CumulativeEnergyMeasured",
"code": 0,
"mfgCode": null,
"side": "server",
"included": 1
},
{
"name": "PeriodicEnergyMeasured",
"code": 1,
"mfgCode": null,
"side": "server",
"included": 1
}
]
},
{
"name": "Window Covering",
"code": 258,
Expand Down Expand Up @@ -21742,4 +21961,4 @@
}
],
"log": []
}
}
3 changes: 2 additions & 1 deletion examples/all-clusters-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/temperature-control-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/time-synchronization-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/dishwasher-alarm-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/laundry-washer-controls-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/laundry-washer-controls-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/all-clusters-app/all-clusters-common/src"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/electrical-energy-measurement-server"
)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12252,5 +12252,6 @@
"endpointId": 65534,
"networkId": 0
}
]
],
"log": []
}
3 changes: 2 additions & 1 deletion examples/bridge-app/bridge-common/bridge-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -5753,5 +5753,6 @@
"endpointId": 2,
"networkId": 0
}
]
],
"log": []
}
Loading

0 comments on commit 29ea755

Please sign in to comment.