Skip to content

Commit f59323b

Browse files
jamesharrowrestyled-commitsbzbarsky-apple
authored
Added Device Energy Management server.cpp to all-clusters-app (project-chip#30957)
* Fix project-chip#30665 (EVSE) - Changed to use amperage_mA, energy_mWh - removed max on epoch_s - removed access for operate - removed side for events * Fix project-chip#30665 updates to try to get further with ZAP and autogen, but still fails with some parts of regen_all * Added ember-compatibility-functions.cpp which was missing. * Made all types all lowercase to resolve regen_all issues. * Fixed lint issue (trailing whitespace). * Added Device Energy Management server.cpp, added to all-clusters-app.zap and regen_all * Restyled by whitespace * Restyled by clang-format * Fixes based on similar conversations on EVSE review. Made Forecast and PowerAdjustmentCapability Nullable attributes. Added feature support. * Added delegate class to all-clusters-app * Changed ChipLogProgress to Error. Better handling of EnumerateCommands * Aligned EVSE XML to same state as PR#30857 (includes SessionID being Nullable etc and in Fault Event). * Updated Device Energy Management XML to use power_mw, energy_mwh per spec definition. * Updated controller-clusters.zap * regen_all.py * Restyled by whitespace * Regen_all after merging in changes for XML * Fixed types to be signed=true * Fixed 31032 - revert removal of side="server". * regen_all.py * Added Device Energy Management cluster back into all-clusters.zap and regen_all after merging from master. * Compiles but doesn't work. Needs stub to instantiate class * Fixed EnumerateCommands to allow optional ModifyForecastRequest and RequestConstraintBasedForecast commands * Fixed InvokeCommand issues to allow optional commands. * Improved HandleModifyForecastRequest and HandleRequestConstraintBasedForecast in sdk * Updates to add DeviceEnergyManagement to all-clusters. * Compiles and links * Sync file in energy-management-app * Updated DEM to support SetPowerAdjustmentCapability and SetForecast methods. * Updated based on review comments. Changed Epoch to be Matter 2000 based epochs. * Turned on commands in DEM. Added DEM cluster server to energy-management-app. * Added more comments to Delegate to describe expected behaviour. * Updated BUILD.gn to remove duplicated files from all-clusters-common and energy-management-common * Aim to fix compile issues on other platforms due to logging of %d * Restyled by gn * Updated build files to remove duplicate copies from all-clusters-common to energy-management-common * Fixed ESP32 include path * Added DEM into energy-management-app - refactored main.cpp. * Added DEM into EVSEManufacturerImpl.h * Fix - avoid using global namespace in header file * Restyled by gn * Updated CMakeLists.txt to remove duplicate energy-management files. * Added device-energy-management-server to ESP32 all-clusters CMakeLists.txt * Removed return at end of void function. * Added include to all-clusters-minimal in ESP32 * Removed __FUNCTION__ from logs * Removed stray %s * Added FeatureMap handling in sdk (not in ember) * Removed extra chip:: * Used CHIP_ERROR_FORMAT, err.Format() mechanism * Refactored StartTimeAdjust based on review comments. * Removed unnecessary Write Attributes function * Beginnings of Session handling * Added beginnings of EVConnected,EVNotDetected,EnergyTransferStarted,EnergyTransferStopped handling. State machine is not finished. Callback to read Energy Meter added * Added framework for EVSE Test Event triggers * Added EnergyEvseTestEventTrigger delegates * Restyled by whitespace * Restyled by gn * Added :energy-evse-test-event-trigger to public_deps to see if it resolves build errors * Restyled by gn * Fixed Darwin compile error - do not use else after return * Refactored code so that the EvseManufacturer instance could be retrieved for Test Event triggers * Started adding TC_EEVSE_2_2.py * Updated TC_EEVSE_2_2.py to support test events. Still needs to handle reading of Logged Events and verifying they are correct. * Refactored Handling of TestEvents to allow clear, and better error handling. * Refactored state handling by decomposing into state machine events where similar functions are performed based on state transition. Fixed TC chargingEnabledUntil cast to int. Note gets to step 6e * Fixed step 6e caused by not setting the cable limit / maxHardwareCurrentLimit in test events * Added comment to clarify purpose and definition of test eventtrigger field values. * Fixed several bugs in test script * Made SetChargingEnabledUntil take a nullable type. * Removed Reference to step 5c, and moved reading of SessionID to step 4b. More TC_EEVSE_2_2 bug fixes. Added event checking. Still fails at step 14. Does not have enable timeout timer implemented * Fixed issue with not detecting 2nd plug in event, and session ID not incrementing. Now test case passes all the way. * Restyled by isort * Made some attributes persisted per spec. * Added attributes to zcl.json to mark them as implemented in attributeAccessInterfaceAttributes * Ran regen_all.py after changing zcl.json * Fixed incorrect type - not picked up by all compilers. * Re-ran bootstrap, and then regen-all - to pick up more zap generated fixes * Added provisional handling for Faults * Added new test event triggers to help test Fault and Diagnostics * Added TC_EEVSE_2_4 * Fix lint issue - unused datetime modules. * Committed suggested change to comment * Added TC_EEVSE_2_5.py to support DiagnosticsCommand testing. Also changed the SupplyState reverting to Disabled once diagnostics is complete to match the spec. * Created a helper EEVSE base class to avoid repetition in the different test cases. * Restyled by isort * Fixed Lint issues * Revamped TC_EEVSE_2_5 to match spec behaviour (cannot start diagnostics unless Disabled). Also removed hard-coded endpoint ids in Utils * Implemented timer to disable the EVSE automatically. * Added documentation to cover concern about long-lived bytespan in enableKey * Fixed Lint and build issues on other platforms * Restyled by isort * Implemented some of the feedback on PR * Refactored HwSetState to use nested switch statements to be clear that all enums are caught. * Fixed error messages * Test scripts: Removed hardcoded endpoint 1 (use --endpoint 1 in args), allowed the enableKey to be passed in using --hex-arg enableKey:000102030405060708090a0b0c0d0e0f * Made enum class for callbacks and improved documentation comments based on feedback. * Fixed another python lint issue. * Updated README.md with help on how to build for test event triggers, using chip-repl and python testing. * Tweaks to README.md to avoid Myst syntax highlighting issues. * Improved error logging around GetEpochTS() * Made main use std::unique_ptr instead of using new/delete per PR comments. Also moved GetEVSEManufacturer declaration to header file. * Fixing MISSPELL issues in README.md * Small change missed in main.cpp missed in unique_ptr change. * Changed all-clusters app stubs to use unique_ptr style instead of new/delete. * Removed unhelpful comment * Restyled by whitespace * Fixes project-chip#31061 Updated DEVICE_TYPE to 0x050C now this has been allocated * Small correction to description in test case. * Update examples/energy-management-app/energy-management-common/include/EnergyEvseDelegateImpl.h Co-authored-by: Boris Zbarsky <bzbarsky@apple.com> * Touched file to retrigger restyled job * Removed whitespace which was added to trigger restyled to rerun * Removed potentially unsafe code before merging into PR project-chip#30957 * Renamed variable and replaced auto with type so it is clearer to reader. --------- Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
1 parent 09f014c commit f59323b

File tree

37 files changed

+2758
-1536
lines changed

37 files changed

+2758
-1536
lines changed

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

+220-13
Original file line numberDiff line numberDiff line change
@@ -3920,6 +3920,185 @@ provisional cluster ElectricalEnergyMeasurement = 145 {
39203920
readonly attribute int16u clusterRevision = 65533;
39213921
}
39223922

3923+
/** This cluster allows a client to manage the power draw of a device. An example of such a client could be an Energy Management System (EMS) which controls an Energy Smart Appliance (ESA). */
3924+
provisional cluster DeviceEnergyManagement = 152 {
3925+
revision 2;
3926+
3927+
enum CauseEnum : enum8 {
3928+
kNormalCompletion = 0;
3929+
kOffline = 1;
3930+
kFault = 2;
3931+
kUserOptOut = 3;
3932+
}
3933+
3934+
enum CostTypeEnum : enum8 {
3935+
kFinancial = 0;
3936+
kGHGEmissions = 1;
3937+
kComfort = 2;
3938+
kTemperature = 3;
3939+
}
3940+
3941+
enum ESAStateEnum : enum8 {
3942+
kOffline = 0;
3943+
kOnline = 1;
3944+
kFault = 2;
3945+
kUserOptOut = 3;
3946+
kPowerAdjustActive = 4;
3947+
kPaused = 5;
3948+
}
3949+
3950+
enum ESATypeEnum : enum8 {
3951+
kEVSE = 0;
3952+
kSpaceHeating = 1;
3953+
kWaterHeating = 2;
3954+
kSpaceCooling = 3;
3955+
kSpaceHeatingCooling = 4;
3956+
kBatteryStorage = 5;
3957+
kSolarPV = 6;
3958+
kFridgeFreezer = 7;
3959+
kWashingMachine = 8;
3960+
kDishwasher = 9;
3961+
kCooking = 10;
3962+
kHomeWaterPump = 11;
3963+
kIrrigationWaterPump = 12;
3964+
kPoolPump = 13;
3965+
kOther = 255;
3966+
}
3967+
3968+
bitmap Feature : bitmap32 {
3969+
kPowerAdjustment = 0x1;
3970+
kPowerForecastReporting = 0x2;
3971+
kStateForecastReporting = 0x4;
3972+
kForecastAdjustment = 0x8;
3973+
}
3974+
3975+
struct CostStruct {
3976+
CostTypeEnum costType = 0;
3977+
int32s value = 1;
3978+
int8u decimalPoints = 2;
3979+
optional int16u currency = 3;
3980+
}
3981+
3982+
struct SlotStruct {
3983+
elapsed_s minDuration = 0;
3984+
elapsed_s maxDuration = 1;
3985+
elapsed_s defaultDuration = 2;
3986+
elapsed_s elapsedSlotTime = 3;
3987+
elapsed_s remainingSlotTime = 4;
3988+
boolean slotIsPauseable = 5;
3989+
elapsed_s minPauseDuration = 6;
3990+
elapsed_s maxPauseDuration = 7;
3991+
optional int16u manufacturerESAState = 8;
3992+
optional power_mw nominalPower = 9;
3993+
optional power_mw minPower = 10;
3994+
optional power_mw maxPower = 11;
3995+
optional energy_mwh nominalEnergy = 12;
3996+
optional CostStruct costs[] = 13;
3997+
optional power_mw minPowerAdjustment = 14;
3998+
optional power_mw maxPowerAdjustment = 15;
3999+
optional elapsed_s minDurationAdjustment = 16;
4000+
optional elapsed_s maxDurationAdjustment = 17;
4001+
}
4002+
4003+
struct ForecastStruct {
4004+
int16u forecastId = 0;
4005+
nullable int16u activeSlotNumber = 1;
4006+
epoch_s startTime = 2;
4007+
epoch_s endTime = 3;
4008+
optional nullable epoch_s earliestStartTime = 4;
4009+
optional epoch_s latestEndTime = 5;
4010+
boolean isPauseable = 6;
4011+
SlotStruct slots[] = 7;
4012+
}
4013+
4014+
struct ConstraintsStruct {
4015+
epoch_s startTime = 0;
4016+
elapsed_s duration = 1;
4017+
optional power_mw nominalPower = 2;
4018+
optional energy_mwh maximumEnergy = 3;
4019+
optional int8s loadControl = 4;
4020+
}
4021+
4022+
struct PowerAdjustStruct {
4023+
power_mw minPower = 0;
4024+
power_mw maxPower = 1;
4025+
elapsed_s minDuration = 2;
4026+
elapsed_s maxDuration = 3;
4027+
}
4028+
4029+
struct SlotAdjustmentStruct {
4030+
int8u slotIndex = 0;
4031+
power_mw nominalPower = 1;
4032+
elapsed_s duration = 2;
4033+
}
4034+
4035+
info event PowerAdjustStart = 0 {
4036+
}
4037+
4038+
info event PowerAdjustEnd = 1 {
4039+
CauseEnum cause = 0;
4040+
elapsed_s duration = 1;
4041+
energy_mwh energyUse = 2;
4042+
}
4043+
4044+
info event Paused = 2 {
4045+
}
4046+
4047+
info event Resumed = 3 {
4048+
}
4049+
4050+
readonly attribute ESATypeEnum ESAType = 0;
4051+
readonly attribute boolean ESACanGenerate = 1;
4052+
readonly attribute ESAStateEnum ESAState = 2;
4053+
readonly attribute power_mw absMinPower = 3;
4054+
readonly attribute power_mw absMaxPower = 4;
4055+
readonly attribute optional nullable PowerAdjustStruct powerAdjustmentCapability[] = 5;
4056+
readonly attribute optional nullable ForecastStruct forecast = 6;
4057+
readonly attribute command_id generatedCommandList[] = 65528;
4058+
readonly attribute command_id acceptedCommandList[] = 65529;
4059+
readonly attribute event_id eventList[] = 65530;
4060+
readonly attribute attrib_id attributeList[] = 65531;
4061+
readonly attribute bitmap32 featureMap = 65532;
4062+
readonly attribute int16u clusterRevision = 65533;
4063+
4064+
request struct PowerAdjustRequestRequest {
4065+
power_mw power = 0;
4066+
elapsed_s duration = 1;
4067+
}
4068+
4069+
request struct StartTimeAdjustRequestRequest {
4070+
epoch_s requestedStartTime = 0;
4071+
}
4072+
4073+
request struct PauseRequestRequest {
4074+
elapsed_s duration = 0;
4075+
}
4076+
4077+
request struct ModifyForecastRequestRequest {
4078+
int32u forecastId = 0;
4079+
SlotAdjustmentStruct slotAdjustments[] = 1;
4080+
}
4081+
4082+
request struct RequestConstraintBasedForecastRequest {
4083+
ConstraintsStruct constraints[] = 0;
4084+
}
4085+
4086+
/** Allows a client to request an adjustment in the power consumption of an ESA for a specified duration. */
4087+
command PowerAdjustRequest(PowerAdjustRequestRequest): DefaultSuccess = 0;
4088+
/** Allows a client to cancel an ongoing PowerAdjustmentRequest operation. */
4089+
command CancelPowerAdjustRequest(): DefaultSuccess = 1;
4090+
/** Allows a client to adjust the start time of a Forecast sequence that has not yet started operation (i.e. where the current Forecast StartTime is in the future). */
4091+
command StartTimeAdjustRequest(StartTimeAdjustRequestRequest): DefaultSuccess = 2;
4092+
/** Allows a client to temporarily pause an operation and reduce the ESAs energy demand. */
4093+
command PauseRequest(PauseRequestRequest): DefaultSuccess = 3;
4094+
/** Allows a client to cancel the PauseRequest command and enable earlier resumption of operation. */
4095+
command ResumeRequest(): DefaultSuccess = 4;
4096+
/** Allows a client to modify a Forecast within the limits allowed by the ESA. */
4097+
command ModifyForecastRequest(ModifyForecastRequestRequest): DefaultSuccess = 5;
4098+
/** Allows a client to ask the ESA to recompute its Forecast based on power and time constraints. */
4099+
command RequestConstraintBasedForecast(RequestConstraintBasedForecastRequest): DefaultSuccess = 6;
4100+
}
4101+
39234102
/** Electric Vehicle Supply Equipment (EVSE) is equipment used to charge an Electric Vehicle (EV) or Plug-In Hybrid Electric Vehicle. This cluster provides an interface to the functionality of Electric Vehicle Supply Equipment (EVSE) management. */
39244103
provisional cluster EnergyEvse = 153 {
39254104
revision 2;
@@ -7737,25 +7916,53 @@ endpoint 1 {
77377916
ram attribute clusterRevision default = 1;
77387917
}
77397918

7919+
server cluster DeviceEnergyManagement {
7920+
emits event PowerAdjustStart;
7921+
emits event PowerAdjustEnd;
7922+
emits event Paused;
7923+
emits event Resumed;
7924+
callback attribute ESAType;
7925+
callback attribute ESACanGenerate;
7926+
callback attribute ESAState;
7927+
callback attribute absMinPower;
7928+
callback attribute absMaxPower;
7929+
callback attribute powerAdjustmentCapability;
7930+
callback attribute forecast;
7931+
callback attribute generatedCommandList;
7932+
callback attribute acceptedCommandList;
7933+
callback attribute eventList;
7934+
callback attribute attributeList;
7935+
callback attribute featureMap;
7936+
ram attribute clusterRevision default = 2;
7937+
7938+
handle command PowerAdjustRequest;
7939+
handle command CancelPowerAdjustRequest;
7940+
handle command StartTimeAdjustRequest;
7941+
handle command PauseRequest;
7942+
handle command ResumeRequest;
7943+
handle command ModifyForecastRequest;
7944+
handle command RequestConstraintBasedForecast;
7945+
}
7946+
77407947
server cluster EnergyEvse {
7741-
callback attribute state default = 0;
7742-
callback attribute supplyState default = 0;
7743-
callback attribute faultState default = 0;
7744-
callback attribute chargingEnabledUntil default = 0;
7745-
callback attribute dischargingEnabledUntil default = 0;
7746-
callback attribute circuitCapacity default = 0;
7747-
callback attribute minimumChargeCurrent default = 6000;
7748-
callback attribute maximumChargeCurrent default = 0;
7749-
callback attribute maximumDischargeCurrent default = 0;
7750-
callback attribute userMaximumChargeCurrent default = 0;
7751-
callback attribute randomizationDelayWindow default = 600;
7948+
callback attribute state;
7949+
callback attribute supplyState;
7950+
callback attribute faultState;
7951+
callback attribute chargingEnabledUntil;
7952+
callback attribute dischargingEnabledUntil;
7953+
callback attribute circuitCapacity;
7954+
callback attribute minimumChargeCurrent;
7955+
callback attribute maximumChargeCurrent;
7956+
callback attribute maximumDischargeCurrent;
7957+
callback attribute userMaximumChargeCurrent;
7958+
callback attribute randomizationDelayWindow;
77527959
callback attribute numberOfWeeklyTargets default = 0;
77537960
callback attribute numberOfDailyTargets default = 1;
77547961
callback attribute nextChargeStartTime;
77557962
callback attribute nextChargeTargetTime;
77567963
callback attribute nextChargeRequiredEnergy;
77577964
callback attribute nextChargeTargetSoC;
7758-
callback attribute approximateEVEfficiency default = 0xFFFF;
7965+
callback attribute approximateEVEfficiency;
77597966
callback attribute stateOfCharge;
77607967
callback attribute batteryCapacity;
77617968
callback attribute vehicleID;
@@ -7767,7 +7974,7 @@ endpoint 1 {
77677974
callback attribute acceptedCommandList;
77687975
callback attribute eventList;
77697976
callback attribute attributeList;
7770-
ram attribute featureMap default = 0;
7977+
callback attribute featureMap;
77717978
ram attribute clusterRevision default = 2;
77727979

77737980
handle command GetTargetsResponse;

0 commit comments

Comments
 (0)