Skip to content

Commit

Permalink
31479 updated DEM xml to take latest spec changes (#31483)
Browse files Browse the repository at this point in the history
* Autogen'd the XML from Hasty's Alchemy tool and some minor hand edits to correct.

* Updated ZAP files and regen_all.py

* Fixed compile issues caused by type changes. Included GetOptOutState() to allow the new OptOutState attribute to be handled.

* Added helper function to handle optout checking of OptOutState attribute against Adjustment cause in existing commands

* Added CancelRequest command handler. Updated Conformance feature flags and generated commands. Some code clean up in sdk layer with returning of Status (success was missing in places)

* Added AjustmentCause to delegate API for commands that should use it.

* Fixed build on all-clusters-app

* Merged changes into all-clusters-app.zap and energy-management-app.zap and regen all

* Update src/app/clusters/device-energy-management-server/device-energy-management-server.cpp

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>

---------

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>
  • Loading branch information
jamesharrow and bzbarsky-apple committed Jan 19, 2024
1 parent 45ad139 commit 45aa5b7
Show file tree
Hide file tree
Showing 57 changed files with 2,127 additions and 361 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3990,13 +3990,19 @@ provisional cluster ElectricalEnergyMeasurement = 145 {

/** 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). */
provisional cluster DeviceEnergyManagement = 152 {
revision 2;
revision 3;

enum AdjustmentCauseEnum : enum8 {
kLocalOptimization = 0;
kGridOptimization = 1;
}

enum CauseEnum : enum8 {
kNormalCompletion = 0;
kOffline = 1;
kFault = 2;
kUserOptOut = 3;
kCancelled = 4;
}

enum CostTypeEnum : enum8 {
Expand All @@ -4010,9 +4016,8 @@ provisional cluster DeviceEnergyManagement = 152 {
kOffline = 0;
kOnline = 1;
kFault = 2;
kUserOptOut = 3;
kPowerAdjustActive = 4;
kPaused = 5;
kPowerAdjustActive = 3;
kPaused = 4;
}

enum ESATypeEnum : enum8 {
Expand All @@ -4033,11 +4038,27 @@ provisional cluster DeviceEnergyManagement = 152 {
kOther = 255;
}

enum ForecastUpdateReasonEnum : enum8 {
kInternalOptimization = 0;
kLocalOptimization = 1;
kGridOptimization = 2;
}

enum OptOutStateEnum : enum8 {
kNoOptOut = 0;
kLocalOptOut = 1;
kGridOptOut = 2;
kOptOut = 3;
}

bitmap Feature : bitmap32 {
kPowerAdjustment = 0x1;
kPowerForecastReporting = 0x2;
kStateForecastReporting = 0x4;
kForecastAdjustment = 0x8;
kStartTimeAdjustment = 0x8;
kPausable = 0x10;
kForecastAdjustment = 0x20;
kConstraintBasedAdjustment = 0x40;
}

struct CostStruct {
Expand All @@ -4053,9 +4074,9 @@ provisional cluster DeviceEnergyManagement = 152 {
elapsed_s defaultDuration = 2;
elapsed_s elapsedSlotTime = 3;
elapsed_s remainingSlotTime = 4;
boolean slotIsPauseable = 5;
elapsed_s minPauseDuration = 6;
elapsed_s maxPauseDuration = 7;
optional boolean slotIsPauseable = 5;
optional elapsed_s minPauseDuration = 6;
optional elapsed_s maxPauseDuration = 7;
optional int16u manufacturerESAState = 8;
optional power_mw nominalPower = 9;
optional power_mw minPower = 10;
Expand All @@ -4077,6 +4098,7 @@ provisional cluster DeviceEnergyManagement = 152 {
optional epoch_s latestEndTime = 5;
boolean isPauseable = 6;
SlotStruct slots[] = 7;
ForecastUpdateReasonEnum forecastUpdateReason = 8;
}

struct ConstraintsStruct {
Expand Down Expand Up @@ -4113,6 +4135,7 @@ provisional cluster DeviceEnergyManagement = 152 {
}

info event Resumed = 3 {
CauseEnum cause = 0;
}

readonly attribute ESATypeEnum ESAType = 0;
Expand All @@ -4122,6 +4145,7 @@ provisional cluster DeviceEnergyManagement = 152 {
readonly attribute power_mw absMaxPower = 4;
readonly attribute optional nullable PowerAdjustStruct powerAdjustmentCapability[] = 5;
readonly attribute optional nullable ForecastStruct forecast = 6;
readonly attribute optional OptOutStateEnum optOutState = 7;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
Expand All @@ -4132,23 +4156,28 @@ provisional cluster DeviceEnergyManagement = 152 {
request struct PowerAdjustRequestRequest {
power_mw power = 0;
elapsed_s duration = 1;
AdjustmentCauseEnum cause = 2;
}

request struct StartTimeAdjustRequestRequest {
epoch_s requestedStartTime = 0;
AdjustmentCauseEnum cause = 1;
}

request struct PauseRequestRequest {
elapsed_s duration = 0;
AdjustmentCauseEnum cause = 1;
}

request struct ModifyForecastRequestRequest {
int32u forecastId = 0;
SlotAdjustmentStruct slotAdjustments[] = 1;
AdjustmentCauseEnum cause = 2;
}

request struct RequestConstraintBasedForecastRequest {
ConstraintsStruct constraints[] = 0;
AdjustmentCauseEnum cause = 1;
}

/** Allows a client to request an adjustment in the power consumption of an ESA for a specified duration. */
Expand All @@ -4165,6 +4194,8 @@ provisional cluster DeviceEnergyManagement = 152 {
command ModifyForecastRequest(ModifyForecastRequestRequest): DefaultSuccess = 5;
/** Allows a client to ask the ESA to recompute its Forecast based on power and time constraints. */
command RequestConstraintBasedForecast(RequestConstraintBasedForecastRequest): DefaultSuccess = 6;
/** Allows a client to request cancellation of a previous adjustment request in a StartTimeAdjustRequest, ModifyForecastRequest or RequestConstraintBasedForecast command */
command CancelRequest(): DefaultSuccess = 7;
}

/** 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. */
Expand Down Expand Up @@ -8009,12 +8040,13 @@ endpoint 1 {
callback attribute absMaxPower;
callback attribute powerAdjustmentCapability;
callback attribute forecast;
callback attribute optOutState;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
callback attribute attributeList;
callback attribute featureMap;
ram attribute clusterRevision default = 2;
ram attribute clusterRevision default = 3;

handle command PowerAdjustRequest;
handle command CancelPowerAdjustRequest;
Expand All @@ -8023,6 +8055,7 @@ endpoint 1 {
handle command ResumeRequest;
handle command ModifyForecastRequest;
handle command RequestConstraintBasedForecast;
handle command CancelRequest;
}

server cluster EnergyEvse {
Expand Down
58 changes: 41 additions & 17 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
}
],
"package": [
{
"pathRelativity": "relativeToZap",
"path": "../../../src/app/zap-templates/app-templates.json",
"type": "gen-templates-json",
"version": "chip-v1"
},
{
"pathRelativity": "relativeToZap",
"path": "../../../src/app/zap-templates/zcl/zcl-with-test-extensions.json",
"type": "zcl-properties",
"category": "matter",
"version": 1,
"description": "Matter SDK ZCL data with some extensions"
},
{
"pathRelativity": "relativeToZap",
"path": "../../../src/app/zap-templates/app-templates.json",
"type": "gen-templates-json",
"version": "chip-v1"
}
],
"endpointTypes": [
Expand Down Expand Up @@ -8150,7 +8150,7 @@
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand All @@ -8166,7 +8166,7 @@
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand All @@ -8182,7 +8182,7 @@
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand All @@ -8198,7 +8198,7 @@
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand All @@ -8214,7 +8214,7 @@
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand All @@ -8230,7 +8230,7 @@
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand All @@ -8246,7 +8246,7 @@
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand All @@ -8262,7 +8262,7 @@
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand All @@ -8278,7 +8278,7 @@
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down Expand Up @@ -12899,6 +12899,14 @@
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "CancelRequest",
"code": 7,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
}
],
"attributes": [
Expand Down Expand Up @@ -13014,6 +13022,22 @@
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "OptOutState",
"code": 7,
"mfgCode": null,
"side": "server",
"type": "OptOutStateEnum",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "GeneratedCommandList",
"code": 65528,
Expand Down Expand Up @@ -13056,7 +13080,7 @@
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": null,
"defaultValue": "0",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down Expand Up @@ -13104,7 +13128,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "2",
"defaultValue": "3",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ void emberAfDeviceEnergyManagementClusterInitCallback(chip::EndpointId endpointI
gInstance = std::make_unique<DeviceEnergyManagementManager>(
endpointId, *gDelegate,
BitMask<DeviceEnergyManagement::Feature, uint32_t>(
DeviceEnergyManagement::Feature::kPowerForecastReporting, DeviceEnergyManagement::Feature::kStateForecastReporting,
DeviceEnergyManagement::Feature::kPowerAdjustment, DeviceEnergyManagement::Feature::kForecastAdjustment),
BitMask<OptionalCommands, uint32_t>(OptionalCommands::kSupportsModifyForecastRequest,
OptionalCommands::kSupportsRequestConstraintBasedForecast));
DeviceEnergyManagement::Feature::kPowerAdjustment, DeviceEnergyManagement::Feature::kPowerForecastReporting,
DeviceEnergyManagement::Feature::kStateForecastReporting, DeviceEnergyManagement::Feature::kStartTimeAdjustment,
DeviceEnergyManagement::Feature::kPausable, DeviceEnergyManagement::Feature::kForecastAdjustment,
DeviceEnergyManagement::Feature::kConstraintBasedAdjustment));

if (!gInstance)
{
Expand Down
Loading

0 comments on commit 45aa5b7

Please sign in to comment.