diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index 076c291ec6fd96..5c7cdec4c3591c 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -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 { @@ -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 { @@ -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 { @@ -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; @@ -4077,6 +4098,7 @@ provisional cluster DeviceEnergyManagement = 152 { optional epoch_s latestEndTime = 5; boolean isPauseable = 6; SlotStruct slots[] = 7; + ForecastUpdateReasonEnum forecastUpdateReason = 8; } struct ConstraintsStruct { @@ -4113,6 +4135,7 @@ provisional cluster DeviceEnergyManagement = 152 { } info event Resumed = 3 { + CauseEnum cause = 0; } readonly attribute ESATypeEnum ESAType = 0; @@ -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; @@ -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. */ @@ -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. */ @@ -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; @@ -8023,6 +8055,7 @@ endpoint 1 { handle command ResumeRequest; handle command ModifyForecastRequest; handle command RequestConstraintBasedForecast; + handle command CancelRequest; } server cluster EnergyEvse { diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index 1d0d2054ba71fa..21b74ffd223f5e 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -17,12 +17,6 @@ } ], "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", @@ -30,6 +24,12 @@ "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": [ @@ -8150,7 +8150,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -8166,7 +8166,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -8182,7 +8182,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -8198,7 +8198,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -8214,7 +8214,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -8230,7 +8230,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -8246,7 +8246,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -8262,7 +8262,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -8278,7 +8278,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -12899,6 +12899,14 @@ "source": "client", "isIncoming": 1, "isEnabled": 1 + }, + { + "name": "CancelRequest", + "code": 7, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 } ], "attributes": [ @@ -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, @@ -13056,7 +13080,7 @@ "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": null, + "defaultValue": "0", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -13104,7 +13128,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "2", + "defaultValue": "3", "reportable": 1, "minInterval": 1, "maxInterval": 65534, diff --git a/examples/all-clusters-app/all-clusters-common/src/device-energy-management-stub.cpp b/examples/all-clusters-app/all-clusters-common/src/device-energy-management-stub.cpp index 385c1cfa43c8ee..190702c61af464 100644 --- a/examples/all-clusters-app/all-clusters-common/src/device-energy-management-stub.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/device-energy-management-stub.cpp @@ -50,10 +50,10 @@ void emberAfDeviceEnergyManagementClusterInitCallback(chip::EndpointId endpointI gInstance = std::make_unique( endpointId, *gDelegate, BitMask( - DeviceEnergyManagement::Feature::kPowerForecastReporting, DeviceEnergyManagement::Feature::kStateForecastReporting, - DeviceEnergyManagement::Feature::kPowerAdjustment, DeviceEnergyManagement::Feature::kForecastAdjustment), - BitMask(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) { diff --git a/examples/energy-management-app/energy-management-common/energy-management-app.matter b/examples/energy-management-app/energy-management-common/energy-management-app.matter index 6fff020aa05417..56e288bc712b9b 100644 --- a/examples/energy-management-app/energy-management-common/energy-management-app.matter +++ b/examples/energy-management-app/energy-management-common/energy-management-app.matter @@ -902,13 +902,19 @@ cluster GroupKeyManagement = 63 { /** 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 { @@ -922,9 +928,8 @@ provisional cluster DeviceEnergyManagement = 152 { kOffline = 0; kOnline = 1; kFault = 2; - kUserOptOut = 3; - kPowerAdjustActive = 4; - kPaused = 5; + kPowerAdjustActive = 3; + kPaused = 4; } enum ESATypeEnum : enum8 { @@ -945,11 +950,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 { @@ -965,9 +986,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; @@ -989,6 +1010,7 @@ provisional cluster DeviceEnergyManagement = 152 { optional epoch_s latestEndTime = 5; boolean isPauseable = 6; SlotStruct slots[] = 7; + ForecastUpdateReasonEnum forecastUpdateReason = 8; } struct ConstraintsStruct { @@ -1025,6 +1047,7 @@ provisional cluster DeviceEnergyManagement = 152 { } info event Resumed = 3 { + CauseEnum cause = 0; } readonly attribute ESATypeEnum ESAType = 0; @@ -1034,6 +1057,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; @@ -1044,23 +1068,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. */ @@ -1077,6 +1106,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. */ @@ -1478,12 +1509,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; @@ -1492,6 +1524,7 @@ endpoint 1 { handle command ResumeRequest; handle command ModifyForecastRequest; handle command RequestConstraintBasedForecast; + handle command CancelRequest; } server cluster EnergyEvse { diff --git a/examples/energy-management-app/energy-management-common/energy-management-app.zap b/examples/energy-management-app/energy-management-common/energy-management-app.zap index 92430d761980ab..d00270b2ed5717 100644 --- a/examples/energy-management-app/energy-management-common/energy-management-app.zap +++ b/examples/energy-management-app/energy-management-common/energy-management-app.zap @@ -2581,6 +2581,14 @@ "source": "client", "isIncoming": 1, "isEnabled": 1 + }, + { + "name": "CancelRequest", + "code": 7, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 } ], "attributes": [ @@ -2696,6 +2704,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, @@ -2786,7 +2810,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "2", + "defaultValue": "3", "reportable": 1, "minInterval": 1, "maxInterval": 65534, diff --git a/examples/energy-management-app/energy-management-common/include/DeviceEnergyManagementDelegateImpl.h b/examples/energy-management-app/energy-management-common/include/DeviceEnergyManagementDelegateImpl.h index 464a683510b3d7..973e1e622576a4 100644 --- a/examples/energy-management-app/energy-management-common/include/DeviceEnergyManagementDelegateImpl.h +++ b/examples/energy-management-app/energy-management-common/include/DeviceEnergyManagementDelegateImpl.h @@ -36,16 +36,19 @@ namespace DeviceEnergyManagement { class DeviceEnergyManagementDelegate : public DeviceEnergyManagement::Delegate { public: - virtual Status PowerAdjustRequest(const int64_t power, const uint32_t duration) override; + virtual Status PowerAdjustRequest(const int64_t power, const uint32_t duration, AdjustmentCauseEnum cause) override; virtual Status CancelPowerAdjustRequest() override; - virtual Status StartTimeAdjustRequest(const uint32_t requestedStartTime) override; - virtual Status PauseRequest(const uint32_t duration) override; + virtual Status StartTimeAdjustRequest(const uint32_t requestedStartTime, AdjustmentCauseEnum cause) override; + virtual Status PauseRequest(const uint32_t duration, AdjustmentCauseEnum cause) override; virtual Status ResumeRequest() override; virtual Status ModifyForecastRequest(const uint32_t forecastId, - const DataModel::DecodableList & slotAdjustments) override; - virtual Status RequestConstraintBasedForecast( - const DataModel::DecodableList & constraints) override; + const DataModel::DecodableList & slotAdjustments, + AdjustmentCauseEnum cause) override; + virtual Status + RequestConstraintBasedForecast(const DataModel::DecodableList & constraints, + AdjustmentCauseEnum cause) override; + virtual Status CancelRequest() override; // ------------------------------------------------------------------ // Get attribute methods @@ -56,6 +59,7 @@ class DeviceEnergyManagementDelegate : public DeviceEnergyManagement::Delegate virtual int64_t GetAbsMaxPower() override; virtual Attributes::PowerAdjustmentCapability::TypeInfo::Type GetPowerAdjustmentCapability() override; virtual DataModel::Nullable GetForecast() override; + virtual OptOutStateEnum GetOptOutState() override; // ------------------------------------------------------------------ // Set attribute methods @@ -75,6 +79,8 @@ class DeviceEnergyManagementDelegate : public DeviceEnergyManagement::Delegate int64_t mAbsMaxPower; Attributes::PowerAdjustmentCapability::TypeInfo::Type mPowerAdjustmentCapability; DataModel::Nullable mForecast; + // Default to NoOptOut + OptOutStateEnum mOptOutState = OptOutStateEnum::kNoOptOut; }; } // namespace DeviceEnergyManagement diff --git a/examples/energy-management-app/energy-management-common/include/DeviceEnergyManagementManager.h b/examples/energy-management-app/energy-management-common/include/DeviceEnergyManagementManager.h index 6d131dd4ae90fa..aec875ff0d1f99 100644 --- a/examples/energy-management-app/energy-management-common/include/DeviceEnergyManagementManager.h +++ b/examples/energy-management-app/energy-management-common/include/DeviceEnergyManagementManager.h @@ -31,9 +31,8 @@ using namespace chip::app::Clusters::DeviceEnergyManagement; class DeviceEnergyManagementManager : public Instance { public: - DeviceEnergyManagementManager(EndpointId aEndpointId, DeviceEnergyManagementDelegate & aDelegate, Feature aFeature, - OptionalCommands aOptionalCmds) : - DeviceEnergyManagement::Instance(aEndpointId, aDelegate, aFeature, aOptionalCmds) + DeviceEnergyManagementManager(EndpointId aEndpointId, DeviceEnergyManagementDelegate & aDelegate, Feature aFeature) : + DeviceEnergyManagement::Instance(aEndpointId, aDelegate, aFeature) { mDelegate = &aDelegate; } diff --git a/examples/energy-management-app/energy-management-common/src/DeviceEnergyManagementDelegateImpl.cpp b/examples/energy-management-app/energy-management-common/src/DeviceEnergyManagementDelegateImpl.cpp index 4d4d9bf05bbdbb..28c6b8942ff493 100644 --- a/examples/energy-management-app/energy-management-common/src/DeviceEnergyManagementDelegateImpl.cpp +++ b/examples/energy-management-app/energy-management-common/src/DeviceEnergyManagementDelegateImpl.cpp @@ -49,7 +49,7 @@ using CostsList = DataModel::List; * 6) generate a PowerAdjustEnd event with cause NormalCompletion * 7) if necessary, update the forecast with new expected end time */ -Status DeviceEnergyManagementDelegate::PowerAdjustRequest(const int64_t power, const uint32_t duration) +Status DeviceEnergyManagementDelegate::PowerAdjustRequest(const int64_t power, const uint32_t duration, AdjustmentCauseEnum cause) { Status status = Status::UnsupportedCommand; // Status::Success; @@ -98,7 +98,7 @@ Status DeviceEnergyManagementDelegate::CancelPowerAdjustRequest() * 1) update the forecast attribute with the revised start time * 2) send a callback notification to the appliance so it can refresh its internal schedule */ -Status DeviceEnergyManagementDelegate::StartTimeAdjustRequest(const uint32_t requestedStartTime) +Status DeviceEnergyManagementDelegate::StartTimeAdjustRequest(const uint32_t requestedStartTime, AdjustmentCauseEnum cause) { DataModel::Nullable forecast = GetForecast(); @@ -136,7 +136,7 @@ Status DeviceEnergyManagementDelegate::StartTimeAdjustRequest(const uint32_t req * 6) generate a Resumed event * 7) if necessary, update the forecast with new expected end time */ -Status DeviceEnergyManagementDelegate::PauseRequest(const uint32_t duration) +Status DeviceEnergyManagementDelegate::PauseRequest(const uint32_t duration, AdjustmentCauseEnum cause) { Status status = Status::UnsupportedCommand; // Status::Success; // TODO: implement the behaviour above @@ -181,7 +181,8 @@ Status DeviceEnergyManagementDelegate::ResumeRequest() * 3) notify the appliance to follow the revised schedule */ Status DeviceEnergyManagementDelegate::ModifyForecastRequest( - const uint32_t forecastId, const DataModel::DecodableList & slotAdjustments) + const uint32_t forecastId, const DataModel::DecodableList & slotAdjustments, + AdjustmentCauseEnum cause) { Status status = Status::UnsupportedCommand; // Status::Success; @@ -202,7 +203,25 @@ Status DeviceEnergyManagementDelegate::ModifyForecastRequest( * 3) notify the appliance to follow the revised schedule */ Status DeviceEnergyManagementDelegate::RequestConstraintBasedForecast( - const DataModel::DecodableList & constraints) + const DataModel::DecodableList & constraints, AdjustmentCauseEnum cause) +{ + Status status = Status::UnsupportedCommand; // Status::Success; + // TODO: implement the behaviour above + return status; +} + +/** + * @brief Delegate handler for CancelRequest + * + * Note: This is a more complex use-case and requires higher-level work by the delegate. + * + * It SHALL: + * 1) Check if the forecastUpdateReason was already InternalOptimization (and reject the command) + * 2) Update its forecast (based on its optimization strategy) ignoring previous requests + * 3) Update its Forecast attribute to match its new intended operation, and update the + * ForecastStruct.ForecastUpdateReason to `Internal Optimization`. + */ +Status DeviceEnergyManagementDelegate::CancelRequest() { Status status = Status::UnsupportedCommand; // Status::Success; // TODO: implement the behaviour above @@ -246,6 +265,11 @@ DataModel::Nullable DeviceEnergyManagementDelegat return mForecast; } +OptOutStateEnum DeviceEnergyManagementDelegate::GetOptOutState() +{ + return mOptOutState; +} + // ------------------------------------------------------------------ // Set attribute methods diff --git a/examples/energy-management-app/linux/main.cpp b/examples/energy-management-app/linux/main.cpp index 23ec97e267f45d..df544484975f4f 100644 --- a/examples/energy-management-app/linux/main.cpp +++ b/examples/energy-management-app/linux/main.cpp @@ -73,11 +73,10 @@ CHIP_ERROR DeviceEnergyManagementInit() gDEMInstance = std::make_unique( EndpointId(ENERGY_EVSE_ENDPOINT), *gDEMDelegate, BitMask( - DeviceEnergyManagement::Feature::kPowerForecastReporting, DeviceEnergyManagement::Feature::kStateForecastReporting, - DeviceEnergyManagement::Feature::kPowerAdjustment, DeviceEnergyManagement::Feature::kForecastAdjustment), - BitMask( - DeviceEnergyManagement::OptionalCommands::kSupportsModifyForecastRequest, - DeviceEnergyManagement::OptionalCommands::kSupportsRequestConstraintBasedForecast)); + DeviceEnergyManagement::Feature::kPowerAdjustment, DeviceEnergyManagement::Feature::kPowerForecastReporting, + DeviceEnergyManagement::Feature::kStateForecastReporting, DeviceEnergyManagement::Feature::kStartTimeAdjustment, + DeviceEnergyManagement::Feature::kPausable, DeviceEnergyManagement::Feature::kForecastAdjustment, + DeviceEnergyManagement::Feature::kConstraintBasedAdjustment)); if (!gDEMInstance) { diff --git a/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp b/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp index bfe3cac5f2e89e..7836e91295412f 100644 --- a/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp +++ b/src/app/clusters/device-energy-management-server/device-energy-management-server.cpp @@ -53,11 +53,6 @@ bool Instance::HasFeature(Feature aFeature) const return mFeature.Has(aFeature); } -bool Instance::SupportsOptCmd(OptionalCommands aOptionalCmds) const -{ - return mOptionalCmds.Has(aOptionalCmds); -} - // AttributeAccessInterface CHIP_ERROR Instance::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) { @@ -87,6 +82,16 @@ CHIP_ERROR Instance::Read(const ConcreteReadAttributePath & aPath, AttributeValu return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); } return aEncoder.Encode(mDelegate.GetForecast()); + case OptOutState::Id: + /* PA | STA | PAU | FA | CON */ + if (!HasFeature(Feature::kPowerAdjustment) && !HasFeature(Feature::kStartTimeAdjustment) && + !HasFeature(Feature::kPausable) && !HasFeature(Feature::kForecastAdjustment) && + !HasFeature(Feature::kConstraintBasedAdjustment)) + { + return CHIP_IM_GLOBAL_STATUS(UnsupportedAttribute); + } + return aEncoder.Encode(mDelegate.GetOptOutState()); + /* FeatureMap - is held locally */ case FeatureMap::Id: return aEncoder.Encode(mFeature); @@ -112,28 +117,33 @@ CHIP_ERROR Instance::EnumerateAcceptedCommands(const ConcreteClusterPath & clust } } - if (HasFeature(Feature::kForecastAdjustment)) + if (HasFeature(Feature::kStartTimeAdjustment)) { - for (auto && cmd : { - StartTimeAdjustRequest::Id, - PauseRequest::Id, - ResumeRequest::Id, - }) - { - VerifyOrExit(callback(cmd, context) == Loop::Continue, /**/); - } + VerifyOrExit(callback(StartTimeAdjustRequest::Id, context) == Loop::Continue, /**/); + } + + if (HasFeature(Feature::kPausable)) + { + VerifyOrExit(callback(PauseRequest::Id, context) == Loop::Continue, /**/); + VerifyOrExit(callback(ResumeRequest::Id, context) == Loop::Continue, /**/); } - if (SupportsOptCmd(OptionalCommands::kSupportsModifyForecastRequest)) + if (HasFeature(Feature::kForecastAdjustment)) { VerifyOrExit(callback(ModifyForecastRequest::Id, context) == Loop::Continue, /**/); } - if (SupportsOptCmd(OptionalCommands::kSupportsRequestConstraintBasedForecast)) + if (HasFeature(Feature::kConstraintBasedAdjustment)) { VerifyOrExit(callback(RequestConstraintBasedForecast::Id, context) == Loop::Continue, /**/); } + if (HasFeature(Feature::kStartTimeAdjustment) || HasFeature(Feature::kForecastAdjustment) || + HasFeature(Feature::kConstraintBasedAdjustment)) + { + VerifyOrExit(callback(CancelRequest::Id, context) == Loop::Continue, /**/); + } + exit: return CHIP_NO_ERROR; } @@ -169,7 +179,7 @@ void Instance::InvokeCommand(HandlerContext & handlerContext) } return; case StartTimeAdjustRequest::Id: - if (!HasFeature(Feature::kForecastAdjustment)) + if (!HasFeature(Feature::kStartTimeAdjustment)) { handlerContext.mCommandHandler.AddStatus(handlerContext.mRequestPath, Status::UnsupportedCommand); } @@ -181,7 +191,7 @@ void Instance::InvokeCommand(HandlerContext & handlerContext) } return; case PauseRequest::Id: - if (!HasFeature(Feature::kForecastAdjustment)) + if (!HasFeature(Feature::kPausable)) { handlerContext.mCommandHandler.AddStatus(handlerContext.mRequestPath, Status::UnsupportedCommand); } @@ -192,7 +202,7 @@ void Instance::InvokeCommand(HandlerContext & handlerContext) } return; case ResumeRequest::Id: - if (!HasFeature(Feature::kForecastAdjustment)) + if (!HasFeature(Feature::kPausable)) { handlerContext.mCommandHandler.AddStatus(handlerContext.mRequestPath, Status::UnsupportedCommand); } @@ -203,7 +213,7 @@ void Instance::InvokeCommand(HandlerContext & handlerContext) } return; case ModifyForecastRequest::Id: - if (!SupportsOptCmd(OptionalCommands::kSupportsModifyForecastRequest)) + if (!HasFeature(Feature::kForecastAdjustment)) { handlerContext.mCommandHandler.AddStatus(handlerContext.mRequestPath, Status::UnsupportedCommand); } @@ -215,7 +225,7 @@ void Instance::InvokeCommand(HandlerContext & handlerContext) } return; case RequestConstraintBasedForecast::Id: - if (!SupportsOptCmd(OptionalCommands::kSupportsRequestConstraintBasedForecast)) + if (!HasFeature(Feature::kConstraintBasedAdjustment)) { handlerContext.mCommandHandler.AddStatus(handlerContext.mRequestPath, Status::UnsupportedCommand); } @@ -226,19 +236,88 @@ void Instance::InvokeCommand(HandlerContext & handlerContext) [this](HandlerContext & ctx, const auto & commandData) { HandleRequestConstraintBasedForecast(ctx, commandData); }); } return; + case CancelRequest::Id: + if (!HasFeature(Feature::kStartTimeAdjustment) && !HasFeature(Feature::kForecastAdjustment) && + !HasFeature(Feature::kConstraintBasedAdjustment)) + { + handlerContext.mCommandHandler.AddStatus(handlerContext.mRequestPath, Status::UnsupportedCommand); + } + else + { + HandleCommand( + handlerContext, [this](HandlerContext & ctx, const auto & commandData) { HandleCancelRequest(ctx, commandData); }); + } + return; } } -void Instance::HandlePowerAdjustRequest(HandlerContext & ctx, const Commands::PowerAdjustRequest::DecodableType & commandData) +Status Instance::CheckOptOutAllowsRequest(AdjustmentCauseEnum adjustmentCause) { - int64_t power = commandData.power; - uint32_t durationSec = commandData.duration; - bool validArgs = false; - Status status = Status::Success; + OptOutStateEnum optOutState = mDelegate.GetOptOutState(); + + if (adjustmentCause == AdjustmentCauseEnum::kUnknownEnumValue) + { + ChipLogError(Zcl, "DEM: adjustment cause is invalid (%d)", static_cast(adjustmentCause)); + return Status::InvalidValue; + } + + switch (optOutState) + { + case OptOutStateEnum::kNoOptOut: /* User has NOT opted out so allow it */ + ChipLogProgress(Zcl, "DEM: OptOutState = kNoOptOut"); + return Status::Success; + + case OptOutStateEnum::kLocalOptOut: /* User has opted out from Local only*/ + ChipLogProgress(Zcl, "DEM: OptOutState = kLocalOptOut"); + switch (adjustmentCause) + { + case AdjustmentCauseEnum::kGridOptimization: + return Status::Success; + case AdjustmentCauseEnum::kLocalOptimization: + default: + return Status::Failure; + } + + case OptOutStateEnum::kGridOptOut: /* User has opted out from Grid only */ + ChipLogProgress(Zcl, "DEM: OptOutState = kGridOptOut"); + switch (adjustmentCause) + { + case AdjustmentCauseEnum::kLocalOptimization: + return Status::Success; + case AdjustmentCauseEnum::kGridOptimization: + default: + return Status::Failure; + } + + case OptOutStateEnum::kOptOut: /* User has opted out from both local and grid */ + ChipLogProgress(Zcl, "DEM: OptOutState = kOptOut"); + return Status::Failure; + default: + ChipLogError(Zcl, "DEM: invalid optOutState %d", static_cast(optOutState)); + return Status::InvalidValue; + } +} + +void Instance::HandlePowerAdjustRequest(HandlerContext & ctx, const Commands::PowerAdjustRequest::DecodableType & commandData) +{ + Status status; + bool validArgs = false; PowerAdjustmentCapability::TypeInfo::Type powerAdjustmentCapability; - powerAdjustmentCapability = mDelegate.GetPowerAdjustmentCapability(); + int64_t power = commandData.power; + uint32_t durationSec = commandData.duration; + AdjustmentCauseEnum adjustmentCause = commandData.cause; + + status = CheckOptOutAllowsRequest(adjustmentCause); + if (status != Status::Success) + { + ChipLogError(Zcl, "DEM: PowerAdjustRequest command rejected"); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); + return; + } + + powerAdjustmentCapability = mDelegate.GetPowerAdjustmentCapability(); if (powerAdjustmentCapability.IsNull()) { ChipLogError(Zcl, "DEM: powerAdjustmentCapability IsNull"); @@ -267,7 +346,7 @@ void Instance::HandlePowerAdjustRequest(HandlerContext & ctx, const Commands::Po ChipLogProgress(Zcl, "DEM: Good PowerAdjustRequest() args."); - status = mDelegate.PowerAdjustRequest(power, durationSec); + status = mDelegate.PowerAdjustRequest(power, durationSec, adjustmentCause); ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); if (status != Status::Success) { @@ -278,11 +357,10 @@ void Instance::HandlePowerAdjustRequest(HandlerContext & ctx, const Commands::Po void Instance::HandleCancelPowerAdjustRequest(HandlerContext & ctx, const Commands::CancelPowerAdjustRequest::DecodableType & commandData) { - Status status = Status::Success; - ESAStateEnum esaStatus; + Status status; /* Check that the ESA state is PowerAdjustActive */ - esaStatus = mDelegate.GetESAState(); + ESAStateEnum esaStatus = mDelegate.GetESAState(); if (ESAStateEnum::kPowerAdjustActive != esaStatus) { ChipLogError(Zcl, "DEM: kPowerAdjustActive != esaStatus"); @@ -302,24 +380,27 @@ void Instance::HandleCancelPowerAdjustRequest(HandlerContext & ctx, void Instance::HandleStartTimeAdjustRequest(HandlerContext & ctx, const Commands::StartTimeAdjustRequest::DecodableType & commandData) { - Status status = Status::Success; - uint32_t earliestStartTimeEpoch = 0; - uint32_t latestEndTimeEpoch = 0; - uint32_t requestedStartTimeEpoch = commandData.requestedStartTime; + Status status; + uint32_t earliestStartTimeEpoch = 0; + uint32_t latestEndTimeEpoch = 0; uint32_t duration; - DataModel::Nullable forecastNullable = mDelegate.GetForecast(); + uint32_t requestedStartTimeEpoch = commandData.requestedStartTime; + AdjustmentCauseEnum adjustmentCause = commandData.cause; - if (forecastNullable.IsNull()) + status = CheckOptOutAllowsRequest(adjustmentCause); + if (status != Status::Success) { - ChipLogError(Zcl, "DEM: Forecast is Null"); - ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure); + ChipLogError(Zcl, "DEM: StartTimeAdjustRequest command rejected"); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); return; } - if (ESAStateEnum::kUserOptOut == mDelegate.GetESAState()) + DataModel::Nullable forecastNullable = mDelegate.GetForecast(); + + if (forecastNullable.IsNull()) { - ChipLogError(Zcl, "DEM: ESAState = kUserOptOut"); + ChipLogError(Zcl, "DEM: Forecast is Null"); ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure); return; } @@ -395,7 +476,7 @@ void Instance::HandleStartTimeAdjustRequest(HandlerContext & ctx, } ChipLogProgress(Zcl, "DEM: Good requestedStartTimeEpoch %ld.", static_cast(requestedStartTimeEpoch)); - status = mDelegate.StartTimeAdjustRequest(requestedStartTimeEpoch); + status = mDelegate.StartTimeAdjustRequest(requestedStartTimeEpoch, adjustmentCause); ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); if (status != Status::Success) { @@ -410,18 +491,20 @@ void Instance::HandlePauseRequest(HandlerContext & ctx, const Commands::PauseReq CHIP_ERROR err = CHIP_NO_ERROR; DataModel::Nullable forecast = mDelegate.GetForecast(); - uint32_t duration = commandData.duration; + uint32_t duration = commandData.duration; + AdjustmentCauseEnum adjustmentCause = commandData.cause; - if (forecast.IsNull()) + status = CheckOptOutAllowsRequest(adjustmentCause); + if (status != Status::Success) { - ChipLogError(Zcl, "DEM: Forecast is Null"); - ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure); + ChipLogError(Zcl, "DEM: PauseRequest command rejected"); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); return; } - if (ESAStateEnum::kUserOptOut == mDelegate.GetESAState()) + if (forecast.IsNull()) { - ChipLogError(Zcl, "DEM: ESAState = kUserOptOut"); + ChipLogError(Zcl, "DEM: Forecast is Null"); ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure); return; } @@ -446,15 +529,37 @@ void Instance::HandlePauseRequest(HandlerContext & ctx, const Commands::PauseReq return; } - if (!forecast.Value().slots[activeSlotNumber].slotIsPauseable) + /* We expect that there should be a slotIsPauseable entry (but it is optional) */ + if (!forecast.Value().slots[activeSlotNumber].slotIsPauseable.HasValue()) + { + ChipLogError(Zcl, "DEM: activeSlotNumber %d does not include slotIsPauseable.", activeSlotNumber); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure); + return; + } + + if (!forecast.Value().slots[activeSlotNumber].minPauseDuration.HasValue()) + { + ChipLogError(Zcl, "DEM: activeSlotNumber %d does not include minPauseDuration.", activeSlotNumber); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure); + return; + } + + if (!forecast.Value().slots[activeSlotNumber].maxPauseDuration.HasValue()) + { + ChipLogError(Zcl, "DEM: activeSlotNumber %d does not include minPauseDuration.", activeSlotNumber); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure); + return; + } + + if (!forecast.Value().slots[activeSlotNumber].slotIsPauseable.Value()) { ChipLogError(Zcl, "DEM: activeSlotNumber %d is NOT pauseable.", activeSlotNumber); ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::ConstraintError); return; } - if ((duration < forecast.Value().slots[activeSlotNumber].minPauseDuration) && - (duration > forecast.Value().slots[activeSlotNumber].maxPauseDuration)) + if ((duration < forecast.Value().slots[activeSlotNumber].minPauseDuration.Value()) && + (duration > forecast.Value().slots[activeSlotNumber].maxPauseDuration.Value())) { ChipLogError(Zcl, "DEM: out of range pause duration %ld", static_cast(duration)); ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::ConstraintError); @@ -469,19 +574,18 @@ void Instance::HandlePauseRequest(HandlerContext & ctx, const Commands::PauseReq return; } - status = mDelegate.PauseRequest(duration); - ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure); + status = mDelegate.PauseRequest(duration, adjustmentCause); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); if (status != Status::Success) { - ChipLogError(Zcl, "DEM: mDelegate.PauseRequest(%ld) FAILURE", static_cast(duration)); + ChipLogError(Zcl, "DEM: PauseRequest(%ld) FAILURE", static_cast(duration)); return; } } void Instance::HandleResumeRequest(HandlerContext & ctx, const Commands::ResumeRequest::DecodableType & commandData) { - Status status = Status::Success; - DataModel::Nullable forecast = mDelegate.GetForecast(); + Status status; if (ESAStateEnum::kPaused != mDelegate.GetESAState()) { @@ -491,24 +595,28 @@ void Instance::HandleResumeRequest(HandlerContext & ctx, const Commands::ResumeR } status = mDelegate.ResumeRequest(); - ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); if (status != Status::Success) { - ChipLogError(Zcl, "DEM: mDelegate.ResumeRequest() FAILURE"); + ChipLogError(Zcl, "DEM: ResumeRequest FAILURE"); return; } } void Instance::HandleModifyForecastRequest(HandlerContext & ctx, const Commands::ModifyForecastRequest::DecodableType & commandData) { - Status status = Status::Success; - uint32_t forecastId = commandData.forecastId; + Status status; DataModel::Nullable forecast; - if (ESAStateEnum::kUserOptOut == mDelegate.GetESAState()) + uint32_t forecastId = commandData.forecastId; + DataModel::DecodableList slotAdjustments = commandData.slotAdjustments; + AdjustmentCauseEnum adjustmentCause = commandData.cause; + + status = CheckOptOutAllowsRequest(adjustmentCause); + if (status != Status::Success) { - ChipLogError(Zcl, "DEM: ESAState = kUserOptOut"); - ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure); + ChipLogError(Zcl, "DEM: ModifyForecastRequest command rejected"); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); return; } @@ -520,12 +628,11 @@ void Instance::HandleModifyForecastRequest(HandlerContext & ctx, const Commands: return; } - DataModel::DecodableList slotAdjustments = commandData.slotAdjustments; - status = mDelegate.ModifyForecastRequest(forecastId, slotAdjustments); + status = mDelegate.ModifyForecastRequest(forecastId, slotAdjustments, adjustmentCause); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); if (status != Status::Success) { - ChipLogError(Zcl, "DEM: mDelegate.ModifyForecastRequest() FAILURE"); - ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure); + ChipLogError(Zcl, "DEM: ModifyForecastRequest FAILURE"); return; } } @@ -533,20 +640,37 @@ void Instance::HandleModifyForecastRequest(HandlerContext & ctx, const Commands: void Instance::HandleRequestConstraintBasedForecast(HandlerContext & ctx, const Commands::RequestConstraintBasedForecast::DecodableType & commandData) { - Status status = Status::Success; + Status status; - if (ESAStateEnum::kUserOptOut == mDelegate.GetESAState()) + DataModel::DecodableList constraints = commandData.constraints; + AdjustmentCauseEnum adjustmentCause = commandData.cause; + + status = CheckOptOutAllowsRequest(adjustmentCause); + if (status != Status::Success) { - ChipLogError(Zcl, "DEM: ESAState = kUserOptOut"); - ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure); + ChipLogError(Zcl, "DEM: RequestConstraintBasedForecast command rejected"); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); return; } - status = mDelegate.RequestConstraintBasedForecast(commandData.constraints); + status = mDelegate.RequestConstraintBasedForecast(constraints, adjustmentCause); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); if (status != Status::Success) { - ChipLogError(Zcl, "DEM: mDelegate.commandData.constraints() FAILURE"); - ctx.mCommandHandler.AddStatus(ctx.mRequestPath, Status::Failure); + ChipLogError(Zcl, "DEM: RequestConstraintBasedForecast FAILURE"); + return; + } +} + +void Instance::HandleCancelRequest(HandlerContext & ctx, const Commands::CancelRequest::DecodableType & commandData) +{ + Status status; + + status = mDelegate.CancelRequest(); + ctx.mCommandHandler.AddStatus(ctx.mRequestPath, status); + if (status != Status::Success) + { + ChipLogError(Zcl, "DEM: CancelRequest FAILURE"); return; } } diff --git a/src/app/clusters/device-energy-management-server/device-energy-management-server.h b/src/app/clusters/device-energy-management-server/device-energy-management-server.h index 7ab6a8aa60f306..3620379d4ed8e2 100644 --- a/src/app/clusters/device-energy-management-server/device-energy-management-server.h +++ b/src/app/clusters/device-energy-management-server/device-energy-management-server.h @@ -52,7 +52,7 @@ class Delegate * @param duration The duration that the ESA SHALL maintain the requested power for. * @return Success if the adjustment is accepted; otherwise the command SHALL be rejected with appropriate error. */ - virtual Status PowerAdjustRequest(const int64_t power, const uint32_t duration) = 0; + virtual Status PowerAdjustRequest(const int64_t power, const uint32_t duration, AdjustmentCauseEnum cause) = 0; /** * @brief Delegate SHALL make the ESA end the active power adjustment session & return to normal (or idle) power levels. @@ -76,7 +76,7 @@ class Delegate * @return Success if the StartTime in the Forecast is updated, otherwise the command SHALL be rejected with appropriate * IM_Status. */ - virtual Status StartTimeAdjustRequest(const uint32_t requestedStartTime) = 0; + virtual Status StartTimeAdjustRequest(const uint32_t requestedStartTime, AdjustmentCauseEnum cause) = 0; /** * @brief Delegate handler for PauseRequest command @@ -91,7 +91,7 @@ class Delegate * @param duration Duration that the ESA SHALL be paused for. * @return Success if the ESA is paused, otherwise returns other IM_Status. */ - virtual Status PauseRequest(const uint32_t duration) = 0; + virtual Status PauseRequest(const uint32_t duration, AdjustmentCauseEnum cause) = 0; /** * @brief Delegate handler for ResumeRequest command @@ -119,7 +119,8 @@ class Delegate * SHALL be rejected returning other IM_Status. */ virtual Status ModifyForecastRequest(const uint32_t forecastId, - const DataModel::DecodableList & slotAdjustments) = 0; + const DataModel::DecodableList & slotAdjustments, + AdjustmentCauseEnum cause) = 0; /** * @brief Delegate handler for RequestConstraintBasedForecast @@ -132,8 +133,27 @@ class Delegate * @param constraints Sequence of turn up/down power requests that the ESA is being asked to constrain its operation within. * @return Success if successful, otherwise the command SHALL be rejected returning other IM_Status. */ - virtual Status - RequestConstraintBasedForecast(const DataModel::DecodableList & constraints) = 0; + virtual Status RequestConstraintBasedForecast(const DataModel::DecodableList & constraints, + AdjustmentCauseEnum cause) = 0; + + /** + * @brief Delegate handler for CancelRequest + * + * The ESA SHALL attempt to cancel the effects of any previous adjustment request commands, and re-evaluate its + * forecast for intended operation ignoring those previous requests. + * + * If the ESA ForecastStruct ForecastUpdateReason was already `Internal Optimization`, then the command SHALL + * be rejected with FAILURE. + * + * If the command is accepted, the ESA SHALL update its ESAState if required, and the command status returned + * SHALL be SUCCESS. + * + * The ESA SHALL update its Forecast attribute to match its new intended operation, and update the + * ForecastStruct.ForecastUpdateReason to `Internal Optimization` + * + * @return Success if successful, otherwise the command SHALL be rejected returning other IM_Status. + */ + virtual Status CancelRequest() = 0; // ------------------------------------------------------------------ // Get attribute methods @@ -144,6 +164,7 @@ class Delegate virtual int64_t GetAbsMaxPower() = 0; virtual PowerAdjustmentCapability::TypeInfo::Type GetPowerAdjustmentCapability() = 0; virtual DataModel::Nullable GetForecast() = 0; + virtual OptOutStateEnum GetOptOutState() = 0; // ------------------------------------------------------------------ // Set attribute methods @@ -159,18 +180,12 @@ class Delegate EndpointId mEndpointId = 0; }; -enum class OptionalCommands : uint32_t -{ - kSupportsModifyForecastRequest = 0x1, - kSupportsRequestConstraintBasedForecast = 0x2 -}; - class Instance : public AttributeAccessInterface, public CommandHandlerInterface { public: - Instance(EndpointId aEndpointId, Delegate & aDelegate, Feature aFeature, OptionalCommands aOptionalCmds) : + Instance(EndpointId aEndpointId, Delegate & aDelegate, Feature aFeature) : AttributeAccessInterface(MakeOptional(aEndpointId), Id), CommandHandlerInterface(MakeOptional(aEndpointId), Id), - mDelegate(aDelegate), mFeature(aFeature), mOptionalCmds(aOptionalCmds) + mDelegate(aDelegate), mFeature(aFeature) { /* set the base class delegates endpointId */ mDelegate.SetEndpointId(aEndpointId); @@ -182,12 +197,10 @@ class Instance : public AttributeAccessInterface, public CommandHandlerInterface void Shutdown(); bool HasFeature(Feature aFeature) const; - bool SupportsOptCmd(OptionalCommands aOptionalCmds) const; private: Delegate & mDelegate; BitMask mFeature; - BitMask mOptionalCmds; // AttributeAccessInterface CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override; @@ -197,6 +210,7 @@ class Instance : public AttributeAccessInterface, public CommandHandlerInterface void InvokeCommand(HandlerContext & handlerContext) override; CHIP_ERROR EnumerateAcceptedCommands(const ConcreteClusterPath & cluster, CommandIdCallback callback, void * context) override; + Status CheckOptOutAllowsRequest(AdjustmentCauseEnum adjustmentCause); void HandlePowerAdjustRequest(HandlerContext & ctx, const Commands::PowerAdjustRequest::DecodableType & commandData); void HandleCancelPowerAdjustRequest(HandlerContext & ctx, const Commands::CancelPowerAdjustRequest::DecodableType & commandData); @@ -206,6 +220,7 @@ class Instance : public AttributeAccessInterface, public CommandHandlerInterface void HandleModifyForecastRequest(HandlerContext & ctx, const Commands::ModifyForecastRequest::DecodableType & commandData); void HandleRequestConstraintBasedForecast(HandlerContext & ctx, const Commands::RequestConstraintBasedForecast::DecodableType & commandData); + void HandleCancelRequest(HandlerContext & ctx, const Commands::CancelRequest::DecodableType & commandData); }; } // namespace DeviceEnergyManagement diff --git a/src/app/zap-templates/zcl/data-model/chip/device-energy-management-cluster.xml b/src/app/zap-templates/zcl/data-model/chip/device-energy-management-cluster.xml index 1d98820d274442..01aef8e7bc06ae 100644 --- a/src/app/zap-templates/zcl/data-model/chip/device-energy-management-cluster.xml +++ b/src/app/zap-templates/zcl/data-model/chip/device-energy-management-cluster.xml @@ -18,11 +18,15 @@ limitations under the License. - - - - + + + + + + + + Device Energy Management Energy Management @@ -31,53 +35,61 @@ limitations under the License. true true 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). - - + - ESAType - ESACanGenerate - ESAState + ESAType + ESACanGenerate + ESAState AbsMinPower AbsMaxPower - PowerAdjustmentCapability + PowerAdjustmentCapability Forecast - + OptOutState + + Allows a client to request an adjustment in the power consumption of an ESA for a specified duration. - Allows a client to request an adjustment in the power consumption of an ESA for a specified duration. + - + Allows a client to cancel an ongoing PowerAdjustmentRequest operation. - - + 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). + + - - + Allows a client to temporarily pause an operation and reduce the ESAs energy demand. + + - + Allows a client to cancel the PauseRequest command and enable earlier resumption of operation. - - - + Allows a client to modify a Forecast within the limits allowed by the ESA. + + + - - + Allows a client to ask the ESA to recompute its Forecast based on power and time constraints. + + + + + Allows a client to request cancellation of a previous adjustment request in a StartTimeAdjustRequest, ModifyForecastRequest or RequestConstraintBasedForecast command PowerAdjustStart PowerAdjustEnd - + @@ -86,6 +98,7 @@ limitations under the License. Resumed + @@ -95,6 +108,7 @@ limitations under the License. + @@ -113,47 +127,75 @@ limitations under the License. + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - + + + + + - - - + + + + - - + + - + - + + + @@ -161,26 +203,28 @@ limitations under the License. - - - + + + - + + + @@ -189,4 +233,5 @@ limitations under the License. + diff --git a/src/app/zap-templates/zcl/zcl-with-test-extensions.json b/src/app/zap-templates/zcl/zcl-with-test-extensions.json index b071fd42c77cb8..7cf25d5e4c4795 100644 --- a/src/app/zap-templates/zcl/zcl-with-test-extensions.json +++ b/src/app/zap-templates/zcl/zcl-with-test-extensions.json @@ -186,6 +186,7 @@ "AbsMaxPower", "PowerAdjustmentCapability", "Forecast", + "OptOutState", "FeatureMap" ], "Energy EVSE": [ diff --git a/src/app/zap-templates/zcl/zcl.json b/src/app/zap-templates/zcl/zcl.json index c645c66e91fc5c..addb14b89f25ba 100644 --- a/src/app/zap-templates/zcl/zcl.json +++ b/src/app/zap-templates/zcl/zcl.json @@ -184,6 +184,7 @@ "AbsMaxPower", "PowerAdjustmentCapability", "Forecast", + "OptOutState", "FeatureMap" ], "Energy EVSE": [ diff --git a/src/controller/data_model/controller-clusters.matter b/src/controller/data_model/controller-clusters.matter index 0a2bc772a5bbf9..ea24f74daa5e4c 100644 --- a/src/controller/data_model/controller-clusters.matter +++ b/src/controller/data_model/controller-clusters.matter @@ -4421,13 +4421,19 @@ provisional cluster DemandResponseLoadControl = 150 { /** 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 { @@ -4441,9 +4447,8 @@ provisional cluster DeviceEnergyManagement = 152 { kOffline = 0; kOnline = 1; kFault = 2; - kUserOptOut = 3; - kPowerAdjustActive = 4; - kPaused = 5; + kPowerAdjustActive = 3; + kPaused = 4; } enum ESATypeEnum : enum8 { @@ -4464,11 +4469,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 { @@ -4484,9 +4505,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; @@ -4508,6 +4529,7 @@ provisional cluster DeviceEnergyManagement = 152 { optional epoch_s latestEndTime = 5; boolean isPauseable = 6; SlotStruct slots[] = 7; + ForecastUpdateReasonEnum forecastUpdateReason = 8; } struct ConstraintsStruct { @@ -4544,6 +4566,7 @@ provisional cluster DeviceEnergyManagement = 152 { } info event Resumed = 3 { + CauseEnum cause = 0; } readonly attribute ESATypeEnum ESAType = 0; @@ -4553,6 +4576,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; @@ -4563,23 +4587,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. */ @@ -4596,6 +4625,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. */ diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java b/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java index 0bbc57d9698c34..1e3f65f09fec06 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ChipClusters.java @@ -29463,6 +29463,7 @@ public static class DeviceEnergyManagementCluster extends BaseChipCluster { private static final long ABS_MAX_POWER_ATTRIBUTE_ID = 4L; private static final long POWER_ADJUSTMENT_CAPABILITY_ATTRIBUTE_ID = 5L; private static final long FORECAST_ATTRIBUTE_ID = 6L; + private static final long OPT_OUT_STATE_ATTRIBUTE_ID = 7L; private static final long GENERATED_COMMAND_LIST_ATTRIBUTE_ID = 65528L; private static final long ACCEPTED_COMMAND_LIST_ATTRIBUTE_ID = 65529L; private static final long EVENT_LIST_ATTRIBUTE_ID = 65530L; @@ -29480,11 +29481,11 @@ public long initWithDevice(long devicePtr, int endpointId) { return 0L; } - public void powerAdjustRequest(DefaultClusterCallback callback, Long power, Long duration) { - powerAdjustRequest(callback, power, duration, 0); + public void powerAdjustRequest(DefaultClusterCallback callback, Long power, Long duration, Integer cause) { + powerAdjustRequest(callback, power, duration, cause, 0); } - public void powerAdjustRequest(DefaultClusterCallback callback, Long power, Long duration, int timedInvokeTimeoutMs) { + public void powerAdjustRequest(DefaultClusterCallback callback, Long power, Long duration, Integer cause, int timedInvokeTimeoutMs) { final long commandId = 0L; ArrayList elements = new ArrayList<>(); @@ -29496,6 +29497,10 @@ public void powerAdjustRequest(DefaultClusterCallback callback, Long power, Long BaseTLVType durationtlvValue = new UIntType(duration); elements.add(new StructElement(durationFieldID, durationtlvValue)); + final long causeFieldID = 2L; + BaseTLVType causetlvValue = new UIntType(cause); + elements.add(new StructElement(causeFieldID, causetlvValue)); + StructType value = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override @@ -29520,11 +29525,11 @@ public void onResponse(StructType invokeStructValue) { }}, commandId, value, timedInvokeTimeoutMs); } - public void startTimeAdjustRequest(DefaultClusterCallback callback, Long requestedStartTime) { - startTimeAdjustRequest(callback, requestedStartTime, 0); + public void startTimeAdjustRequest(DefaultClusterCallback callback, Long requestedStartTime, Integer cause) { + startTimeAdjustRequest(callback, requestedStartTime, cause, 0); } - public void startTimeAdjustRequest(DefaultClusterCallback callback, Long requestedStartTime, int timedInvokeTimeoutMs) { + public void startTimeAdjustRequest(DefaultClusterCallback callback, Long requestedStartTime, Integer cause, int timedInvokeTimeoutMs) { final long commandId = 2L; ArrayList elements = new ArrayList<>(); @@ -29532,6 +29537,10 @@ public void startTimeAdjustRequest(DefaultClusterCallback callback, Long request BaseTLVType requestedStartTimetlvValue = new UIntType(requestedStartTime); elements.add(new StructElement(requestedStartTimeFieldID, requestedStartTimetlvValue)); + final long causeFieldID = 1L; + BaseTLVType causetlvValue = new UIntType(cause); + elements.add(new StructElement(causeFieldID, causetlvValue)); + StructType value = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override @@ -29540,11 +29549,11 @@ public void onResponse(StructType invokeStructValue) { }}, commandId, value, timedInvokeTimeoutMs); } - public void pauseRequest(DefaultClusterCallback callback, Long duration) { - pauseRequest(callback, duration, 0); + public void pauseRequest(DefaultClusterCallback callback, Long duration, Integer cause) { + pauseRequest(callback, duration, cause, 0); } - public void pauseRequest(DefaultClusterCallback callback, Long duration, int timedInvokeTimeoutMs) { + public void pauseRequest(DefaultClusterCallback callback, Long duration, Integer cause, int timedInvokeTimeoutMs) { final long commandId = 3L; ArrayList elements = new ArrayList<>(); @@ -29552,6 +29561,10 @@ public void pauseRequest(DefaultClusterCallback callback, Long duration, int tim BaseTLVType durationtlvValue = new UIntType(duration); elements.add(new StructElement(durationFieldID, durationtlvValue)); + final long causeFieldID = 1L; + BaseTLVType causetlvValue = new UIntType(cause); + elements.add(new StructElement(causeFieldID, causetlvValue)); + StructType value = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override @@ -29576,11 +29589,11 @@ public void onResponse(StructType invokeStructValue) { }}, commandId, value, timedInvokeTimeoutMs); } - public void modifyForecastRequest(DefaultClusterCallback callback, Long forecastId, ArrayList slotAdjustments) { - modifyForecastRequest(callback, forecastId, slotAdjustments, 0); + public void modifyForecastRequest(DefaultClusterCallback callback, Long forecastId, ArrayList slotAdjustments, Integer cause) { + modifyForecastRequest(callback, forecastId, slotAdjustments, cause, 0); } - public void modifyForecastRequest(DefaultClusterCallback callback, Long forecastId, ArrayList slotAdjustments, int timedInvokeTimeoutMs) { + public void modifyForecastRequest(DefaultClusterCallback callback, Long forecastId, ArrayList slotAdjustments, Integer cause, int timedInvokeTimeoutMs) { final long commandId = 5L; ArrayList elements = new ArrayList<>(); @@ -29592,6 +29605,10 @@ public void modifyForecastRequest(DefaultClusterCallback callback, Long forecast BaseTLVType slotAdjustmentstlvValue = ArrayType.generateArrayType(slotAdjustments, (elementslotAdjustments) -> elementslotAdjustments.encodeTlv()); elements.add(new StructElement(slotAdjustmentsFieldID, slotAdjustmentstlvValue)); + final long causeFieldID = 2L; + BaseTLVType causetlvValue = new UIntType(cause); + elements.add(new StructElement(causeFieldID, causetlvValue)); + StructType value = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override @@ -29600,11 +29617,11 @@ public void onResponse(StructType invokeStructValue) { }}, commandId, value, timedInvokeTimeoutMs); } - public void requestConstraintBasedForecast(DefaultClusterCallback callback, ArrayList constraints) { - requestConstraintBasedForecast(callback, constraints, 0); + public void requestConstraintBasedForecast(DefaultClusterCallback callback, ArrayList constraints, Integer cause) { + requestConstraintBasedForecast(callback, constraints, cause, 0); } - public void requestConstraintBasedForecast(DefaultClusterCallback callback, ArrayList constraints, int timedInvokeTimeoutMs) { + public void requestConstraintBasedForecast(DefaultClusterCallback callback, ArrayList constraints, Integer cause, int timedInvokeTimeoutMs) { final long commandId = 6L; ArrayList elements = new ArrayList<>(); @@ -29612,6 +29629,26 @@ public void requestConstraintBasedForecast(DefaultClusterCallback callback, Arra BaseTLVType constraintstlvValue = ArrayType.generateArrayType(constraints, (elementconstraints) -> elementconstraints.encodeTlv()); elements.add(new StructElement(constraintsFieldID, constraintstlvValue)); + final long causeFieldID = 1L; + BaseTLVType causetlvValue = new UIntType(cause); + elements.add(new StructElement(causeFieldID, causetlvValue)); + + StructType value = new StructType(elements); + invoke(new InvokeCallbackImpl(callback) { + @Override + public void onResponse(StructType invokeStructValue) { + callback.onSuccess(); + }}, commandId, value, timedInvokeTimeoutMs); + } + + public void cancelRequest(DefaultClusterCallback callback) { + cancelRequest(callback, 0); + } + + public void cancelRequest(DefaultClusterCallback callback, int timedInvokeTimeoutMs) { + final long commandId = 7L; + + ArrayList elements = new ArrayList<>(); StructType value = new StructType(elements); invoke(new InvokeCallbackImpl(callback) { @Override @@ -29819,6 +29856,31 @@ public void onSuccess(byte[] tlv) { }, FORECAST_ATTRIBUTE_ID, minInterval, maxInterval); } + public void readOptOutStateAttribute( + IntegerAttributeCallback callback) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, OPT_OUT_STATE_ATTRIBUTE_ID); + + readAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + callback.onSuccess(value); + } + }, OPT_OUT_STATE_ATTRIBUTE_ID, true); + } + + public void subscribeOptOutStateAttribute( + IntegerAttributeCallback callback, int minInterval, int maxInterval) { + ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, OPT_OUT_STATE_ATTRIBUTE_ID); + + subscribeAttribute(new ReportCallbackImpl(callback, path) { + @Override + public void onSuccess(byte[] tlv) { + Integer value = ChipTLVValueDecoder.decodeAttributeValue(path, tlv); + } + }, OPT_OUT_STATE_ATTRIBUTE_ID, minInterval, maxInterval); + } + public void readGeneratedCommandListAttribute( GeneratedCommandListAttributeCallback callback) { ChipAttributePath path = ChipAttributePath.newInstance(endpointId, clusterId, GENERATED_COMMAND_LIST_ATTRIBUTE_ID); diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java b/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java index 9f5c25260c131b..c1d134f2735191 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ChipEventStructs.java @@ -3921,13 +3921,18 @@ public String toString() { } } public static class DeviceEnergyManagementClusterResumedEvent { + public Integer cause; + private static final long CAUSE_ID = 0L; public DeviceEnergyManagementClusterResumedEvent( + Integer cause ) { + this.cause = cause; } public StructType encodeTlv() { ArrayList values = new ArrayList<>(); + values.add(new StructElement(CAUSE_ID, new UIntType(cause))); return new StructType(values); } @@ -3936,7 +3941,17 @@ public static DeviceEnergyManagementClusterResumedEvent decodeTlv(BaseTLVType tl if (tlvValue == null || tlvValue.type() != TLVType.Struct) { return null; } + Integer cause = null; + for (StructElement element: ((StructType)tlvValue).value()) { + if (element.contextTagNum() == CAUSE_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + cause = castingValue.value(Integer.class); + } + } + } return new DeviceEnergyManagementClusterResumedEvent( + cause ); } @@ -3944,6 +3959,9 @@ public static DeviceEnergyManagementClusterResumedEvent decodeTlv(BaseTLVType tl public String toString() { StringBuilder output = new StringBuilder(); output.append("DeviceEnergyManagementClusterResumedEvent {\n"); + output.append("\tcause: "); + output.append(cause); + output.append("\n"); output.append("}\n"); return output.toString(); } diff --git a/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java b/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java index c676d026aa2597..6aa20f9a2f796c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ChipStructs.java @@ -6556,9 +6556,9 @@ public static class DeviceEnergyManagementClusterSlotStruct { public Long defaultDuration; public Long elapsedSlotTime; public Long remainingSlotTime; - public Boolean slotIsPauseable; - public Long minPauseDuration; - public Long maxPauseDuration; + public Optional slotIsPauseable; + public Optional minPauseDuration; + public Optional maxPauseDuration; public Optional manufacturerESAState; public Optional nominalPower; public Optional minPower; @@ -6594,9 +6594,9 @@ public DeviceEnergyManagementClusterSlotStruct( Long defaultDuration, Long elapsedSlotTime, Long remainingSlotTime, - Boolean slotIsPauseable, - Long minPauseDuration, - Long maxPauseDuration, + Optional slotIsPauseable, + Optional minPauseDuration, + Optional maxPauseDuration, Optional manufacturerESAState, Optional nominalPower, Optional minPower, @@ -6635,9 +6635,9 @@ public StructType encodeTlv() { values.add(new StructElement(DEFAULT_DURATION_ID, new UIntType(defaultDuration))); values.add(new StructElement(ELAPSED_SLOT_TIME_ID, new UIntType(elapsedSlotTime))); values.add(new StructElement(REMAINING_SLOT_TIME_ID, new UIntType(remainingSlotTime))); - values.add(new StructElement(SLOT_IS_PAUSEABLE_ID, new BooleanType(slotIsPauseable))); - values.add(new StructElement(MIN_PAUSE_DURATION_ID, new UIntType(minPauseDuration))); - values.add(new StructElement(MAX_PAUSE_DURATION_ID, new UIntType(maxPauseDuration))); + values.add(new StructElement(SLOT_IS_PAUSEABLE_ID, slotIsPauseable.map((nonOptionalslotIsPauseable) -> new BooleanType(nonOptionalslotIsPauseable)).orElse(new EmptyType()))); + values.add(new StructElement(MIN_PAUSE_DURATION_ID, minPauseDuration.map((nonOptionalminPauseDuration) -> new UIntType(nonOptionalminPauseDuration)).orElse(new EmptyType()))); + values.add(new StructElement(MAX_PAUSE_DURATION_ID, maxPauseDuration.map((nonOptionalmaxPauseDuration) -> new UIntType(nonOptionalmaxPauseDuration)).orElse(new EmptyType()))); values.add(new StructElement(MANUFACTURER_E_S_A_STATE_ID, manufacturerESAState.map((nonOptionalmanufacturerESAState) -> new UIntType(nonOptionalmanufacturerESAState)).orElse(new EmptyType()))); values.add(new StructElement(NOMINAL_POWER_ID, nominalPower.map((nonOptionalnominalPower) -> new IntType(nonOptionalnominalPower)).orElse(new EmptyType()))); values.add(new StructElement(MIN_POWER_ID, minPower.map((nonOptionalminPower) -> new IntType(nonOptionalminPower)).orElse(new EmptyType()))); @@ -6661,9 +6661,9 @@ public static DeviceEnergyManagementClusterSlotStruct decodeTlv(BaseTLVType tlvV Long defaultDuration = null; Long elapsedSlotTime = null; Long remainingSlotTime = null; - Boolean slotIsPauseable = null; - Long minPauseDuration = null; - Long maxPauseDuration = null; + Optional slotIsPauseable = Optional.empty(); + Optional minPauseDuration = Optional.empty(); + Optional maxPauseDuration = Optional.empty(); Optional manufacturerESAState = Optional.empty(); Optional nominalPower = Optional.empty(); Optional minPower = Optional.empty(); @@ -6703,17 +6703,17 @@ public static DeviceEnergyManagementClusterSlotStruct decodeTlv(BaseTLVType tlvV } else if (element.contextTagNum() == SLOT_IS_PAUSEABLE_ID) { if (element.value(BaseTLVType.class).type() == TLVType.Boolean) { BooleanType castingValue = element.value(BooleanType.class); - slotIsPauseable = castingValue.value(Boolean.class); + slotIsPauseable = Optional.of(castingValue.value(Boolean.class)); } } else if (element.contextTagNum() == MIN_PAUSE_DURATION_ID) { if (element.value(BaseTLVType.class).type() == TLVType.UInt) { UIntType castingValue = element.value(UIntType.class); - minPauseDuration = castingValue.value(Long.class); + minPauseDuration = Optional.of(castingValue.value(Long.class)); } } else if (element.contextTagNum() == MAX_PAUSE_DURATION_ID) { if (element.value(BaseTLVType.class).type() == TLVType.UInt) { UIntType castingValue = element.value(UIntType.class); - maxPauseDuration = castingValue.value(Long.class); + maxPauseDuration = Optional.of(castingValue.value(Long.class)); } } else if (element.contextTagNum() == MANUFACTURER_E_S_A_STATE_ID) { if (element.value(BaseTLVType.class).type() == TLVType.UInt) { @@ -6860,6 +6860,7 @@ public static class DeviceEnergyManagementClusterForecastStruct { public Optional latestEndTime; public Boolean isPauseable; public ArrayList slots; + public Integer forecastUpdateReason; private static final long FORECAST_ID_ID = 0L; private static final long ACTIVE_SLOT_NUMBER_ID = 1L; private static final long START_TIME_ID = 2L; @@ -6868,6 +6869,7 @@ public static class DeviceEnergyManagementClusterForecastStruct { private static final long LATEST_END_TIME_ID = 5L; private static final long IS_PAUSEABLE_ID = 6L; private static final long SLOTS_ID = 7L; + private static final long FORECAST_UPDATE_REASON_ID = 8L; public DeviceEnergyManagementClusterForecastStruct( Integer forecastId, @@ -6877,7 +6879,8 @@ public DeviceEnergyManagementClusterForecastStruct( @Nullable Optional earliestStartTime, Optional latestEndTime, Boolean isPauseable, - ArrayList slots + ArrayList slots, + Integer forecastUpdateReason ) { this.forecastId = forecastId; this.activeSlotNumber = activeSlotNumber; @@ -6887,6 +6890,7 @@ public DeviceEnergyManagementClusterForecastStruct( this.latestEndTime = latestEndTime; this.isPauseable = isPauseable; this.slots = slots; + this.forecastUpdateReason = forecastUpdateReason; } public StructType encodeTlv() { @@ -6899,6 +6903,7 @@ public StructType encodeTlv() { values.add(new StructElement(LATEST_END_TIME_ID, latestEndTime.map((nonOptionallatestEndTime) -> new UIntType(nonOptionallatestEndTime)).orElse(new EmptyType()))); values.add(new StructElement(IS_PAUSEABLE_ID, new BooleanType(isPauseable))); values.add(new StructElement(SLOTS_ID, ArrayType.generateArrayType(slots, (elementslots) -> elementslots.encodeTlv()))); + values.add(new StructElement(FORECAST_UPDATE_REASON_ID, new UIntType(forecastUpdateReason))); return new StructType(values); } @@ -6915,6 +6920,7 @@ public static DeviceEnergyManagementClusterForecastStruct decodeTlv(BaseTLVType Optional latestEndTime = Optional.empty(); Boolean isPauseable = null; ArrayList slots = null; + Integer forecastUpdateReason = null; for (StructElement element: ((StructType)tlvValue).value()) { if (element.contextTagNum() == FORECAST_ID_ID) { if (element.value(BaseTLVType.class).type() == TLVType.UInt) { @@ -6956,6 +6962,11 @@ public static DeviceEnergyManagementClusterForecastStruct decodeTlv(BaseTLVType ArrayType castingValue = element.value(ArrayType.class); slots = castingValue.map((elementcastingValue) -> ChipStructs.DeviceEnergyManagementClusterSlotStruct.decodeTlv(elementcastingValue)); } + } else if (element.contextTagNum() == FORECAST_UPDATE_REASON_ID) { + if (element.value(BaseTLVType.class).type() == TLVType.UInt) { + UIntType castingValue = element.value(UIntType.class); + forecastUpdateReason = castingValue.value(Integer.class); + } } } return new DeviceEnergyManagementClusterForecastStruct( @@ -6966,7 +6977,8 @@ public static DeviceEnergyManagementClusterForecastStruct decodeTlv(BaseTLVType earliestStartTime, latestEndTime, isPauseable, - slots + slots, + forecastUpdateReason ); } @@ -6998,6 +7010,9 @@ public String toString() { output.append("\tslots: "); output.append(slots); output.append("\n"); + output.append("\tforecastUpdateReason: "); + output.append(forecastUpdateReason); + output.append("\n"); output.append("}\n"); return output.toString(); } diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java index cb21688a2ec313..608a378fc281c1 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterIDMapping.java @@ -9359,6 +9359,7 @@ public enum Attribute { AbsMaxPower(4L), PowerAdjustmentCapability(5L), Forecast(6L), + OptOutState(7L), GeneratedCommandList(65528L), AcceptedCommandList(65529L), EventList(65530L), @@ -9415,7 +9416,8 @@ public enum Command { PauseRequest(3L), ResumeRequest(4L), ModifyForecastRequest(5L), - RequestConstraintBasedForecast(6L),; + RequestConstraintBasedForecast(6L), + CancelRequest(7L),; private final long id; Command(long id) { this.id = id; @@ -9433,7 +9435,7 @@ public static Command value(long id) throws NoSuchFieldError { } throw new NoSuchFieldError(); } - }public enum PowerAdjustRequestCommandField {Power(0),Duration(1),; + }public enum PowerAdjustRequestCommandField {Power(0),Duration(1),Cause(2),; private final int id; PowerAdjustRequestCommandField(int id) { this.id = id; @@ -9450,7 +9452,7 @@ public static PowerAdjustRequestCommandField value(int id) throws NoSuchFieldErr } throw new NoSuchFieldError(); } - }public enum StartTimeAdjustRequestCommandField {RequestedStartTime(0),; + }public enum StartTimeAdjustRequestCommandField {RequestedStartTime(0),Cause(1),; private final int id; StartTimeAdjustRequestCommandField(int id) { this.id = id; @@ -9467,7 +9469,7 @@ public static StartTimeAdjustRequestCommandField value(int id) throws NoSuchFiel } throw new NoSuchFieldError(); } - }public enum PauseRequestCommandField {Duration(0),; + }public enum PauseRequestCommandField {Duration(0),Cause(1),; private final int id; PauseRequestCommandField(int id) { this.id = id; @@ -9484,7 +9486,7 @@ public static PauseRequestCommandField value(int id) throws NoSuchFieldError { } throw new NoSuchFieldError(); } - }public enum ModifyForecastRequestCommandField {ForecastId(0),SlotAdjustments(1),; + }public enum ModifyForecastRequestCommandField {ForecastId(0),SlotAdjustments(1),Cause(2),; private final int id; ModifyForecastRequestCommandField(int id) { this.id = id; @@ -9501,7 +9503,7 @@ public static ModifyForecastRequestCommandField value(int id) throws NoSuchField } throw new NoSuchFieldError(); } - }public enum RequestConstraintBasedForecastCommandField {Constraints(0),; + }public enum RequestConstraintBasedForecastCommandField {Constraints(0),Cause(1),; private final int id; RequestConstraintBasedForecastCommandField(int id) { this.id = id; diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java index a030b14c6b218b..342feb2ef08dc4 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterInfoMapping.java @@ -23346,6 +23346,9 @@ public Map> getCommandMap() { CommandParameterInfo deviceEnergyManagementpowerAdjustRequestdurationCommandParameterInfo = new CommandParameterInfo("duration", Long.class, Long.class); deviceEnergyManagementpowerAdjustRequestCommandParams.put("duration",deviceEnergyManagementpowerAdjustRequestdurationCommandParameterInfo); + + CommandParameterInfo deviceEnergyManagementpowerAdjustRequestcauseCommandParameterInfo = new CommandParameterInfo("cause", Integer.class, Integer.class); + deviceEnergyManagementpowerAdjustRequestCommandParams.put("cause",deviceEnergyManagementpowerAdjustRequestcauseCommandParameterInfo); InteractionInfo deviceEnergyManagementpowerAdjustRequestInteractionInfo = new InteractionInfo( (cluster, callback, commandArguments) -> { ((ChipClusters.DeviceEnergyManagementCluster) cluster) @@ -23354,6 +23357,8 @@ public Map> getCommandMap() { commandArguments.get("power") , (Long) commandArguments.get("duration") + , (Integer) + commandArguments.get("cause") ); }, () -> new DelegatedDefaultClusterCallback(), @@ -23377,12 +23382,17 @@ public Map> getCommandMap() { CommandParameterInfo deviceEnergyManagementstartTimeAdjustRequestrequestedStartTimeCommandParameterInfo = new CommandParameterInfo("requestedStartTime", Long.class, Long.class); deviceEnergyManagementstartTimeAdjustRequestCommandParams.put("requestedStartTime",deviceEnergyManagementstartTimeAdjustRequestrequestedStartTimeCommandParameterInfo); + + CommandParameterInfo deviceEnergyManagementstartTimeAdjustRequestcauseCommandParameterInfo = new CommandParameterInfo("cause", Integer.class, Integer.class); + deviceEnergyManagementstartTimeAdjustRequestCommandParams.put("cause",deviceEnergyManagementstartTimeAdjustRequestcauseCommandParameterInfo); InteractionInfo deviceEnergyManagementstartTimeAdjustRequestInteractionInfo = new InteractionInfo( (cluster, callback, commandArguments) -> { ((ChipClusters.DeviceEnergyManagementCluster) cluster) .startTimeAdjustRequest((DefaultClusterCallback) callback , (Long) commandArguments.get("requestedStartTime") + , (Integer) + commandArguments.get("cause") ); }, () -> new DelegatedDefaultClusterCallback(), @@ -23394,12 +23404,17 @@ public Map> getCommandMap() { CommandParameterInfo deviceEnergyManagementpauseRequestdurationCommandParameterInfo = new CommandParameterInfo("duration", Long.class, Long.class); deviceEnergyManagementpauseRequestCommandParams.put("duration",deviceEnergyManagementpauseRequestdurationCommandParameterInfo); + + CommandParameterInfo deviceEnergyManagementpauseRequestcauseCommandParameterInfo = new CommandParameterInfo("cause", Integer.class, Integer.class); + deviceEnergyManagementpauseRequestCommandParams.put("cause",deviceEnergyManagementpauseRequestcauseCommandParameterInfo); InteractionInfo deviceEnergyManagementpauseRequestInteractionInfo = new InteractionInfo( (cluster, callback, commandArguments) -> { ((ChipClusters.DeviceEnergyManagementCluster) cluster) .pauseRequest((DefaultClusterCallback) callback , (Long) commandArguments.get("duration") + , (Integer) + commandArguments.get("cause") ); }, () -> new DelegatedDefaultClusterCallback(), @@ -23424,6 +23439,9 @@ public Map> getCommandMap() { CommandParameterInfo deviceEnergyManagementmodifyForecastRequestforecastIdCommandParameterInfo = new CommandParameterInfo("forecastId", Long.class, Long.class); deviceEnergyManagementmodifyForecastRequestCommandParams.put("forecastId",deviceEnergyManagementmodifyForecastRequestforecastIdCommandParameterInfo); + + CommandParameterInfo deviceEnergyManagementmodifyForecastRequestcauseCommandParameterInfo = new CommandParameterInfo("cause", Integer.class, Integer.class); + deviceEnergyManagementmodifyForecastRequestCommandParams.put("cause",deviceEnergyManagementmodifyForecastRequestcauseCommandParameterInfo); InteractionInfo deviceEnergyManagementmodifyForecastRequestInteractionInfo = new InteractionInfo( (cluster, callback, commandArguments) -> { ((ChipClusters.DeviceEnergyManagementCluster) cluster) @@ -23432,6 +23450,8 @@ public Map> getCommandMap() { commandArguments.get("forecastId") , (ArrayList) commandArguments.get("slotAdjustments") + , (Integer) + commandArguments.get("cause") ); }, () -> new DelegatedDefaultClusterCallback(), @@ -23441,12 +23461,17 @@ public Map> getCommandMap() { Map deviceEnergyManagementrequestConstraintBasedForecastCommandParams = new LinkedHashMap(); + + CommandParameterInfo deviceEnergyManagementrequestConstraintBasedForecastcauseCommandParameterInfo = new CommandParameterInfo("cause", Integer.class, Integer.class); + deviceEnergyManagementrequestConstraintBasedForecastCommandParams.put("cause",deviceEnergyManagementrequestConstraintBasedForecastcauseCommandParameterInfo); InteractionInfo deviceEnergyManagementrequestConstraintBasedForecastInteractionInfo = new InteractionInfo( (cluster, callback, commandArguments) -> { ((ChipClusters.DeviceEnergyManagementCluster) cluster) .requestConstraintBasedForecast((DefaultClusterCallback) callback , (ArrayList) commandArguments.get("constraints") + , (Integer) + commandArguments.get("cause") ); }, () -> new DelegatedDefaultClusterCallback(), @@ -23454,6 +23479,18 @@ public Map> getCommandMap() { ); deviceEnergyManagementClusterInteractionInfoMap.put("requestConstraintBasedForecast", deviceEnergyManagementrequestConstraintBasedForecastInteractionInfo); + Map deviceEnergyManagementcancelRequestCommandParams = new LinkedHashMap(); + InteractionInfo deviceEnergyManagementcancelRequestInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.DeviceEnergyManagementCluster) cluster) + .cancelRequest((DefaultClusterCallback) callback + ); + }, + () -> new DelegatedDefaultClusterCallback(), + deviceEnergyManagementcancelRequestCommandParams + ); + deviceEnergyManagementClusterInteractionInfoMap.put("cancelRequest", deviceEnergyManagementcancelRequestInteractionInfo); + commandMap.put("deviceEnergyManagement", deviceEnergyManagementClusterInteractionInfoMap); Map energyEvseClusterInteractionInfoMap = new LinkedHashMap<>(); diff --git a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java index 95880d5849ce0f..bbd205aaca8b22 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java +++ b/src/controller/java/generated/java/chip/devicecontroller/ClusterReadMapping.java @@ -9336,6 +9336,17 @@ private static Map readDeviceEnergyManagementInteractio readDeviceEnergyManagementPowerAdjustmentCapabilityCommandParams ); result.put("readPowerAdjustmentCapabilityAttribute", readDeviceEnergyManagementPowerAdjustmentCapabilityAttributeInteractionInfo); + Map readDeviceEnergyManagementOptOutStateCommandParams = new LinkedHashMap(); + InteractionInfo readDeviceEnergyManagementOptOutStateAttributeInteractionInfo = new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.DeviceEnergyManagementCluster) cluster).readOptOutStateAttribute( + (ChipClusters.IntegerAttributeCallback) callback + ); + }, + () -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(), + readDeviceEnergyManagementOptOutStateCommandParams + ); + result.put("readOptOutStateAttribute", readDeviceEnergyManagementOptOutStateAttributeInteractionInfo); Map readDeviceEnergyManagementGeneratedCommandListCommandParams = new LinkedHashMap(); InteractionInfo readDeviceEnergyManagementGeneratedCommandListAttributeInteractionInfo = new InteractionInfo( (cluster, callback, commandArguments) -> { diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt new file mode 100644 index 00000000000000..5b4be5cfc2fd55 --- /dev/null +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt @@ -0,0 +1,52 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package chip.devicecontroller.cluster.eventstructs + +import chip.devicecontroller.cluster.* +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class DeviceEnergyManagementClusterResumedEvent(val cause: UInt) { + override fun toString(): String = buildString { + append("DeviceEnergyManagementClusterResumedEvent {\n") + append("\tcause : $cause\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_CAUSE), cause) + endStructure() + } + } + + companion object { + private const val TAG_CAUSE = 0 + + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterResumedEvent { + tlvReader.enterStructure(tlvTag) + val cause = tlvReader.getUInt(ContextSpecificTag(TAG_CAUSE)) + + tlvReader.exitContainer() + + return DeviceEnergyManagementClusterResumedEvent(cause) + } + } +} diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni b/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni index 57b30e5acdf821..dc97dce9da6268 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/files.gni @@ -146,6 +146,7 @@ eventstructs_sources = [ "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt", + "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt", "${chip_root}/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt", diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt index 648d202043f9c5..17e45fa732ea47 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt @@ -32,7 +32,8 @@ class DeviceEnergyManagementClusterForecastStruct( val earliestStartTime: Optional?, val latestEndTime: Optional, val isPauseable: Boolean, - val slots: List + val slots: List, + val forecastUpdateReason: UInt ) { override fun toString(): String = buildString { append("DeviceEnergyManagementClusterForecastStruct {\n") @@ -44,6 +45,7 @@ class DeviceEnergyManagementClusterForecastStruct( append("\tlatestEndTime : $latestEndTime\n") append("\tisPauseable : $isPauseable\n") append("\tslots : $slots\n") + append("\tforecastUpdateReason : $forecastUpdateReason\n") append("}\n") } @@ -76,6 +78,7 @@ class DeviceEnergyManagementClusterForecastStruct( item.toTlv(AnonymousTag, this) } endArray() + put(ContextSpecificTag(TAG_FORECAST_UPDATE_REASON), forecastUpdateReason) endStructure() } } @@ -89,6 +92,7 @@ class DeviceEnergyManagementClusterForecastStruct( private const val TAG_LATEST_END_TIME = 5 private const val TAG_IS_PAUSEABLE = 6 private const val TAG_SLOTS = 7 + private const val TAG_FORECAST_UPDATE_REASON = 8 fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterForecastStruct { tlvReader.enterStructure(tlvTag) @@ -128,6 +132,7 @@ class DeviceEnergyManagementClusterForecastStruct( } tlvReader.exitContainer() } + val forecastUpdateReason = tlvReader.getUInt(ContextSpecificTag(TAG_FORECAST_UPDATE_REASON)) tlvReader.exitContainer() @@ -139,7 +144,8 @@ class DeviceEnergyManagementClusterForecastStruct( earliestStartTime, latestEndTime, isPauseable, - slots + slots, + forecastUpdateReason ) } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt index 736a81804244ce..18759432dc2ce4 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt @@ -30,9 +30,9 @@ class DeviceEnergyManagementClusterSlotStruct( val defaultDuration: ULong, val elapsedSlotTime: ULong, val remainingSlotTime: ULong, - val slotIsPauseable: Boolean, - val minPauseDuration: ULong, - val maxPauseDuration: ULong, + val slotIsPauseable: Optional, + val minPauseDuration: Optional, + val maxPauseDuration: Optional, val manufacturerESAState: Optional, val nominalPower: Optional, val minPower: Optional, @@ -75,9 +75,18 @@ class DeviceEnergyManagementClusterSlotStruct( put(ContextSpecificTag(TAG_DEFAULT_DURATION), defaultDuration) put(ContextSpecificTag(TAG_ELAPSED_SLOT_TIME), elapsedSlotTime) put(ContextSpecificTag(TAG_REMAINING_SLOT_TIME), remainingSlotTime) - put(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE), slotIsPauseable) - put(ContextSpecificTag(TAG_MIN_PAUSE_DURATION), minPauseDuration) - put(ContextSpecificTag(TAG_MAX_PAUSE_DURATION), maxPauseDuration) + if (slotIsPauseable.isPresent) { + val optslotIsPauseable = slotIsPauseable.get() + put(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE), optslotIsPauseable) + } + if (minPauseDuration.isPresent) { + val optminPauseDuration = minPauseDuration.get() + put(ContextSpecificTag(TAG_MIN_PAUSE_DURATION), optminPauseDuration) + } + if (maxPauseDuration.isPresent) { + val optmaxPauseDuration = maxPauseDuration.get() + put(ContextSpecificTag(TAG_MAX_PAUSE_DURATION), optmaxPauseDuration) + } if (manufacturerESAState.isPresent) { val optmanufacturerESAState = manufacturerESAState.get() put(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE), optmanufacturerESAState) @@ -153,9 +162,24 @@ class DeviceEnergyManagementClusterSlotStruct( val defaultDuration = tlvReader.getULong(ContextSpecificTag(TAG_DEFAULT_DURATION)) val elapsedSlotTime = tlvReader.getULong(ContextSpecificTag(TAG_ELAPSED_SLOT_TIME)) val remainingSlotTime = tlvReader.getULong(ContextSpecificTag(TAG_REMAINING_SLOT_TIME)) - val slotIsPauseable = tlvReader.getBoolean(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE)) - val minPauseDuration = tlvReader.getULong(ContextSpecificTag(TAG_MIN_PAUSE_DURATION)) - val maxPauseDuration = tlvReader.getULong(ContextSpecificTag(TAG_MAX_PAUSE_DURATION)) + val slotIsPauseable = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) { + Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) + } else { + Optional.empty() + } + val minPauseDuration = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) + } else { + Optional.empty() + } + val maxPauseDuration = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) + } else { + Optional.empty() + } val manufacturerESAState = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) { Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt index 8481bbf3ccf788..eb68ec47c75ee1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt @@ -114,6 +114,7 @@ class DeviceEnergyManagementCluster( suspend fun powerAdjustRequest( power: Long, duration: UInt, + cause: UByte, timedInvokeTimeout: Duration? = null ) { val commandId: UInt = 0u @@ -126,6 +127,9 @@ class DeviceEnergyManagementCluster( val TAG_DURATION_REQ: Int = 1 tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) + + val TAG_CAUSE_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) tlvWriter.endStructure() val request: InvokeRequest = @@ -159,6 +163,7 @@ class DeviceEnergyManagementCluster( suspend fun startTimeAdjustRequest( requestedStartTime: UInt, + cause: UByte, timedInvokeTimeout: Duration? = null ) { val commandId: UInt = 2u @@ -168,6 +173,9 @@ class DeviceEnergyManagementCluster( val TAG_REQUESTED_START_TIME_REQ: Int = 0 tlvWriter.put(ContextSpecificTag(TAG_REQUESTED_START_TIME_REQ), requestedStartTime) + + val TAG_CAUSE_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) tlvWriter.endStructure() val request: InvokeRequest = @@ -181,7 +189,7 @@ class DeviceEnergyManagementCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun pauseRequest(duration: UInt, timedInvokeTimeout: Duration? = null) { + suspend fun pauseRequest(duration: UInt, cause: UByte, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -189,6 +197,9 @@ class DeviceEnergyManagementCluster( val TAG_DURATION_REQ: Int = 0 tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) + + val TAG_CAUSE_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) tlvWriter.endStructure() val request: InvokeRequest = @@ -223,6 +234,7 @@ class DeviceEnergyManagementCluster( suspend fun modifyForecastRequest( forecastId: UInt, slotAdjustments: List, + cause: UByte, timedInvokeTimeout: Duration? = null ) { val commandId: UInt = 5u @@ -239,6 +251,9 @@ class DeviceEnergyManagementCluster( item.toTlv(AnonymousTag, tlvWriter) } tlvWriter.endArray() + + val TAG_CAUSE_REQ: Int = 2 + tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) tlvWriter.endStructure() val request: InvokeRequest = @@ -254,6 +269,7 @@ class DeviceEnergyManagementCluster( suspend fun requestConstraintBasedForecast( constraints: List, + cause: UByte, timedInvokeTimeout: Duration? = null ) { val commandId: UInt = 6u @@ -267,6 +283,27 @@ class DeviceEnergyManagementCluster( item.toTlv(AnonymousTag, tlvWriter) } tlvWriter.endArray() + + val TAG_CAUSE_REQ: Int = 1 + tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) + tlvWriter.endStructure() + + val request: InvokeRequest = + InvokeRequest( + CommandPath(endpointId, clusterId = CLUSTER_ID, commandId), + tlvPayload = tlvWriter.getEncoded(), + timedRequest = timedInvokeTimeout + ) + + val response: InvokeResponse = controller.invoke(request) + logger.log(Level.FINE, "Invoke command succeeded: ${response}") + } + + suspend fun cancelRequest(timedInvokeTimeout: Duration? = null) { + val commandId: UInt = 7u + + val tlvWriter = TlvWriter() + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -910,6 +947,97 @@ class DeviceEnergyManagementCluster( } } + suspend fun readOptOutStateAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) + + if (response.successes.isEmpty()) { + logger.log(Level.WARNING, "Read command failed") + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } + + logger.log(Level.FINE, "Read command succeeded") + + val attributeData = + response.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { "Optoutstate attribute not found in response" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + return decodedValue + } + + suspend fun subscribeOptOutStateAttribute( + minInterval: Int, + maxInterval: Int + ): Flow { + val ATTRIBUTE_ID: UInt = 7u + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + ) + + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) + + return controller.subscribe(subscribeRequest).transform { subscriptionState -> + when (subscriptionState) { + is SubscriptionState.SubscriptionErrorNotification -> { + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) + } + is SubscriptionState.NodeStateUpdate -> { + val attributeData = + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Optoutstate attribute not found in Node State update" } + + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + } + SubscriptionState.SubscriptionEstablished -> { + emit(UByteSubscriptionState.SubscriptionEstablished) + } + } + } + } + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { val ATTRIBUTE_ID: UInt = 65528u diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt new file mode 100644 index 00000000000000..db5219f72dba0e --- /dev/null +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt @@ -0,0 +1,52 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package matter.controller.cluster.eventstructs + +import matter.controller.cluster.* +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvReader +import matter.tlv.TlvWriter + +class DeviceEnergyManagementClusterResumedEvent(val cause: UByte) { + override fun toString(): String = buildString { + append("DeviceEnergyManagementClusterResumedEvent {\n") + append("\tcause : $cause\n") + append("}\n") + } + + fun toTlv(tlvTag: Tag, tlvWriter: TlvWriter) { + tlvWriter.apply { + startStructure(tlvTag) + put(ContextSpecificTag(TAG_CAUSE), cause) + endStructure() + } + } + + companion object { + private const val TAG_CAUSE = 0 + + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterResumedEvent { + tlvReader.enterStructure(tlvTag) + val cause = tlvReader.getUByte(ContextSpecificTag(TAG_CAUSE)) + + tlvReader.exitContainer() + + return DeviceEnergyManagementClusterResumedEvent(cause) + } + } +} diff --git a/src/controller/java/generated/java/matter/controller/cluster/files.gni b/src/controller/java/generated/java/matter/controller/cluster/files.gni index 635cff6021ba99..42d42d93cbfbc8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/files.gni +++ b/src/controller/java/generated/java/matter/controller/cluster/files.gni @@ -146,6 +146,7 @@ matter_eventstructs_sources = [ "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt", + "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt", "${chip_root}/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt", diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt index 6910c799cd8268..a83d26ee3815d0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt @@ -32,7 +32,8 @@ class DeviceEnergyManagementClusterForecastStruct( val earliestStartTime: Optional?, val latestEndTime: Optional, val isPauseable: Boolean, - val slots: List + val slots: List, + val forecastUpdateReason: UByte ) { override fun toString(): String = buildString { append("DeviceEnergyManagementClusterForecastStruct {\n") @@ -44,6 +45,7 @@ class DeviceEnergyManagementClusterForecastStruct( append("\tlatestEndTime : $latestEndTime\n") append("\tisPauseable : $isPauseable\n") append("\tslots : $slots\n") + append("\tforecastUpdateReason : $forecastUpdateReason\n") append("}\n") } @@ -76,6 +78,7 @@ class DeviceEnergyManagementClusterForecastStruct( item.toTlv(AnonymousTag, this) } endArray() + put(ContextSpecificTag(TAG_FORECAST_UPDATE_REASON), forecastUpdateReason) endStructure() } } @@ -89,6 +92,7 @@ class DeviceEnergyManagementClusterForecastStruct( private const val TAG_LATEST_END_TIME = 5 private const val TAG_IS_PAUSEABLE = 6 private const val TAG_SLOTS = 7 + private const val TAG_FORECAST_UPDATE_REASON = 8 fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterForecastStruct { tlvReader.enterStructure(tlvTag) @@ -128,6 +132,7 @@ class DeviceEnergyManagementClusterForecastStruct( } tlvReader.exitContainer() } + val forecastUpdateReason = tlvReader.getUByte(ContextSpecificTag(TAG_FORECAST_UPDATE_REASON)) tlvReader.exitContainer() @@ -139,7 +144,8 @@ class DeviceEnergyManagementClusterForecastStruct( earliestStartTime, latestEndTime, isPauseable, - slots + slots, + forecastUpdateReason ) } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt index d3121dc411a4de..992a41573e295e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt @@ -30,9 +30,9 @@ class DeviceEnergyManagementClusterSlotStruct( val defaultDuration: UInt, val elapsedSlotTime: UInt, val remainingSlotTime: UInt, - val slotIsPauseable: Boolean, - val minPauseDuration: UInt, - val maxPauseDuration: UInt, + val slotIsPauseable: Optional, + val minPauseDuration: Optional, + val maxPauseDuration: Optional, val manufacturerESAState: Optional, val nominalPower: Optional, val minPower: Optional, @@ -75,9 +75,18 @@ class DeviceEnergyManagementClusterSlotStruct( put(ContextSpecificTag(TAG_DEFAULT_DURATION), defaultDuration) put(ContextSpecificTag(TAG_ELAPSED_SLOT_TIME), elapsedSlotTime) put(ContextSpecificTag(TAG_REMAINING_SLOT_TIME), remainingSlotTime) - put(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE), slotIsPauseable) - put(ContextSpecificTag(TAG_MIN_PAUSE_DURATION), minPauseDuration) - put(ContextSpecificTag(TAG_MAX_PAUSE_DURATION), maxPauseDuration) + if (slotIsPauseable.isPresent) { + val optslotIsPauseable = slotIsPauseable.get() + put(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE), optslotIsPauseable) + } + if (minPauseDuration.isPresent) { + val optminPauseDuration = minPauseDuration.get() + put(ContextSpecificTag(TAG_MIN_PAUSE_DURATION), optminPauseDuration) + } + if (maxPauseDuration.isPresent) { + val optmaxPauseDuration = maxPauseDuration.get() + put(ContextSpecificTag(TAG_MAX_PAUSE_DURATION), optmaxPauseDuration) + } if (manufacturerESAState.isPresent) { val optmanufacturerESAState = manufacturerESAState.get() put(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE), optmanufacturerESAState) @@ -153,9 +162,24 @@ class DeviceEnergyManagementClusterSlotStruct( val defaultDuration = tlvReader.getUInt(ContextSpecificTag(TAG_DEFAULT_DURATION)) val elapsedSlotTime = tlvReader.getUInt(ContextSpecificTag(TAG_ELAPSED_SLOT_TIME)) val remainingSlotTime = tlvReader.getUInt(ContextSpecificTag(TAG_REMAINING_SLOT_TIME)) - val slotIsPauseable = tlvReader.getBoolean(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE)) - val minPauseDuration = tlvReader.getUInt(ContextSpecificTag(TAG_MIN_PAUSE_DURATION)) - val maxPauseDuration = tlvReader.getUInt(ContextSpecificTag(TAG_MAX_PAUSE_DURATION)) + val slotIsPauseable = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) { + Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) + } else { + Optional.empty() + } + val minPauseDuration = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) + } else { + Optional.empty() + } + val maxPauseDuration = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) + } else { + Optional.empty() + } val manufacturerESAState = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) { Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) diff --git a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp index 1ca2a96af986df..2778b037f8e694 100644 --- a/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPAttributeTLVValueDecoder.cpp @@ -22214,26 +22214,60 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_2_remainingSlotTimeClassName.c_str(), newElement_2_remainingSlotTimeCtorSignature.c_str(), jninewElement_2_remainingSlotTime, newElement_2_remainingSlotTime); jobject newElement_2_slotIsPauseable; - std::string newElement_2_slotIsPauseableClassName = "java/lang/Boolean"; - std::string newElement_2_slotIsPauseableCtorSignature = "(Z)V"; - jboolean jninewElement_2_slotIsPauseable = static_cast(entry_2.slotIsPauseable); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2_slotIsPauseableClassName.c_str(), newElement_2_slotIsPauseableCtorSignature.c_str(), - jninewElement_2_slotIsPauseable, newElement_2_slotIsPauseable); + if (!entry_2.slotIsPauseable.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_2_slotIsPauseable); + } + else + { + jobject newElement_2_slotIsPauseableInsideOptional; + std::string newElement_2_slotIsPauseableInsideOptionalClassName = "java/lang/Boolean"; + std::string newElement_2_slotIsPauseableInsideOptionalCtorSignature = "(Z)V"; + jboolean jninewElement_2_slotIsPauseableInsideOptional = + static_cast(entry_2.slotIsPauseable.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_2_slotIsPauseableInsideOptionalClassName.c_str(), + newElement_2_slotIsPauseableInsideOptionalCtorSignature.c_str(), + jninewElement_2_slotIsPauseableInsideOptional, newElement_2_slotIsPauseableInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_2_slotIsPauseableInsideOptional, + newElement_2_slotIsPauseable); + } jobject newElement_2_minPauseDuration; - std::string newElement_2_minPauseDurationClassName = "java/lang/Long"; - std::string newElement_2_minPauseDurationCtorSignature = "(J)V"; - jlong jninewElement_2_minPauseDuration = static_cast(entry_2.minPauseDuration); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2_minPauseDurationClassName.c_str(), newElement_2_minPauseDurationCtorSignature.c_str(), - jninewElement_2_minPauseDuration, newElement_2_minPauseDuration); + if (!entry_2.minPauseDuration.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_2_minPauseDuration); + } + else + { + jobject newElement_2_minPauseDurationInsideOptional; + std::string newElement_2_minPauseDurationInsideOptionalClassName = "java/lang/Long"; + std::string newElement_2_minPauseDurationInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_2_minPauseDurationInsideOptional = static_cast(entry_2.minPauseDuration.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_2_minPauseDurationInsideOptionalClassName.c_str(), + newElement_2_minPauseDurationInsideOptionalCtorSignature.c_str(), + jninewElement_2_minPauseDurationInsideOptional, newElement_2_minPauseDurationInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_2_minPauseDurationInsideOptional, + newElement_2_minPauseDuration); + } jobject newElement_2_maxPauseDuration; - std::string newElement_2_maxPauseDurationClassName = "java/lang/Long"; - std::string newElement_2_maxPauseDurationCtorSignature = "(J)V"; - jlong jninewElement_2_maxPauseDuration = static_cast(entry_2.maxPauseDuration); - chip::JniReferences::GetInstance().CreateBoxedObject( - newElement_2_maxPauseDurationClassName.c_str(), newElement_2_maxPauseDurationCtorSignature.c_str(), - jninewElement_2_maxPauseDuration, newElement_2_maxPauseDuration); + if (!entry_2.maxPauseDuration.HasValue()) + { + chip::JniReferences::GetInstance().CreateOptional(nullptr, newElement_2_maxPauseDuration); + } + else + { + jobject newElement_2_maxPauseDurationInsideOptional; + std::string newElement_2_maxPauseDurationInsideOptionalClassName = "java/lang/Long"; + std::string newElement_2_maxPauseDurationInsideOptionalCtorSignature = "(J)V"; + jlong jninewElement_2_maxPauseDurationInsideOptional = static_cast(entry_2.maxPauseDuration.Value()); + chip::JniReferences::GetInstance().CreateBoxedObject( + newElement_2_maxPauseDurationInsideOptionalClassName.c_str(), + newElement_2_maxPauseDurationInsideOptionalCtorSignature.c_str(), + jninewElement_2_maxPauseDurationInsideOptional, newElement_2_maxPauseDurationInsideOptional); + chip::JniReferences::GetInstance().CreateOptional(newElement_2_maxPauseDurationInsideOptional, + newElement_2_maxPauseDuration); + } jobject newElement_2_manufacturerESAState; if (!entry_2.manufacturerESAState.HasValue()) { @@ -22496,10 +22530,10 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR jmethodID slotStructStructCtor_3; err = chip::JniReferences::GetInstance().FindMethod( env, slotStructStructClass_3, "", - "(Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Boolean;Ljava/" - "lang/Long;Ljava/lang/Long;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/" + "(Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;Ljava/lang/Long;Ljava/util/" + "Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/" "Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/Optional;Ljava/util/" - "Optional;Ljava/util/Optional;)V", + "Optional;Ljava/util/Optional;Ljava/util/Optional;)V", &slotStructStructCtor_3); if (err != CHIP_NO_ERROR || slotStructStructCtor_3 == nullptr) { @@ -22516,6 +22550,13 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR newElement_2_maxPowerAdjustment, newElement_2_minDurationAdjustment, newElement_2_maxDurationAdjustment); chip::JniReferences::GetInstance().AddToList(value_slots, newElement_2); } + jobject value_forecastUpdateReason; + std::string value_forecastUpdateReasonClassName = "java/lang/Integer"; + std::string value_forecastUpdateReasonCtorSignature = "(I)V"; + jint jnivalue_forecastUpdateReason = static_cast(cppValue.Value().forecastUpdateReason); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_forecastUpdateReasonClassName.c_str(), value_forecastUpdateReasonCtorSignature.c_str(), + jnivalue_forecastUpdateReason, value_forecastUpdateReason); jclass forecastStructStructClass_1; err = chip::JniReferences::GetInstance().GetClassRef( @@ -22531,7 +22572,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR err = chip::JniReferences::GetInstance().FindMethod( env, forecastStructStructClass_1, "", "(Ljava/lang/Integer;Ljava/lang/Integer;Ljava/lang/Long;Ljava/lang/Long;Ljava/util/Optional;Ljava/util/" - "Optional;Ljava/lang/Boolean;Ljava/util/ArrayList;)V", + "Optional;Ljava/lang/Boolean;Ljava/util/ArrayList;Ljava/lang/Integer;)V", &forecastStructStructCtor_1); if (err != CHIP_NO_ERROR || forecastStructStructCtor_1 == nullptr) { @@ -22541,8 +22582,24 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR value = env->NewObject(forecastStructStructClass_1, forecastStructStructCtor_1, value_forecastId, value_activeSlotNumber, value_startTime, value_endTime, value_earliestStartTime, - value_latestEndTime, value_isPauseable, value_slots); + value_latestEndTime, value_isPauseable, value_slots, value_forecastUpdateReason); + } + return value; + } + case Attributes::OptOutState::Id: { + using TypeInfo = Attributes::OptOutState::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = app::DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) + { + return nullptr; } + jobject value; + std::string valueClassName = "java/lang/Integer"; + std::string valueCtorSignature = "(I)V"; + jint jnivalue = static_cast(cppValue); + chip::JniReferences::GetInstance().CreateBoxedObject(valueClassName.c_str(), valueCtorSignature.c_str(), jnivalue, + value); return value; } case Attributes::GeneratedCommandList::Id: { diff --git a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp index 2dc5ac3303b7df..d7e0a8debab4ae 100644 --- a/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp +++ b/src/controller/java/zap-generated/CHIPEventTLVValueDecoder.cpp @@ -5282,6 +5282,13 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & { return nullptr; } + jobject value_cause; + std::string value_causeClassName = "java/lang/Integer"; + std::string value_causeCtorSignature = "(I)V"; + jint jnivalue_cause = static_cast(cppValue.cause); + chip::JniReferences::GetInstance().CreateBoxedObject( + value_causeClassName.c_str(), value_causeCtorSignature.c_str(), jnivalue_cause, value_cause); + jclass resumedStructClass; err = chip::JniReferences::GetInstance().GetClassRef( env, "chip/devicecontroller/ChipEventStructs$DeviceEnergyManagementClusterResumedEvent", resumedStructClass); @@ -5292,14 +5299,15 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & } jmethodID resumedStructCtor; - err = chip::JniReferences::GetInstance().FindMethod(env, resumedStructClass, "", "()V", &resumedStructCtor); + err = chip::JniReferences::GetInstance().FindMethod(env, resumedStructClass, "", "(Ljava/lang/Integer;)V", + &resumedStructCtor); if (err != CHIP_NO_ERROR || resumedStructCtor == nullptr) { ChipLogError(Zcl, "Could not find ChipEventStructs$DeviceEnergyManagementClusterResumedEvent constructor"); return nullptr; } - jobject value = env->NewObject(resumedStructClass, resumedStructCtor); + jobject value = env->NewObject(resumedStructClass, resumedStructCtor, value_cause); return value; } diff --git a/src/controller/python/chip/clusters/CHIPClusters.py b/src/controller/python/chip/clusters/CHIPClusters.py index d599bd7f46f730..eddfbd257eb58f 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.py +++ b/src/controller/python/chip/clusters/CHIPClusters.py @@ -6619,6 +6619,7 @@ class ChipClusters: "args": { "power": "int", "duration": "int", + "cause": "int", }, }, 0x00000001: { @@ -6632,6 +6633,7 @@ class ChipClusters: "commandName": "StartTimeAdjustRequest", "args": { "requestedStartTime": "int", + "cause": "int", }, }, 0x00000003: { @@ -6639,6 +6641,7 @@ class ChipClusters: "commandName": "PauseRequest", "args": { "duration": "int", + "cause": "int", }, }, 0x00000004: { @@ -6653,6 +6656,7 @@ class ChipClusters: "args": { "forecastId": "int", "slotAdjustments": "SlotAdjustmentStruct", + "cause": "int", }, }, 0x00000006: { @@ -6660,6 +6664,13 @@ class ChipClusters: "commandName": "RequestConstraintBasedForecast", "args": { "constraints": "ConstraintsStruct", + "cause": "int", + }, + }, + 0x00000007: { + "commandId": 0x00000007, + "commandName": "CancelRequest", + "args": { }, }, }, @@ -6706,6 +6717,12 @@ class ChipClusters: "type": "", "reportable": True, }, + 0x00000007: { + "attributeName": "OptOutState", + "attributeId": 0x00000007, + "type": "int", + "reportable": True, + }, 0x0000FFF8: { "attributeName": "GeneratedCommandList", "attributeId": 0x0000FFF8, diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index 6a2d53df035fe1..4887280c0f91c6 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -23371,6 +23371,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="absMaxPower", Tag=0x00000004, Type=int), ClusterObjectFieldDescriptor(Label="powerAdjustmentCapability", Tag=0x00000005, Type=typing.Union[None, Nullable, typing.List[DeviceEnergyManagement.Structs.PowerAdjustStruct]]), ClusterObjectFieldDescriptor(Label="forecast", Tag=0x00000006, Type=typing.Union[None, Nullable, DeviceEnergyManagement.Structs.ForecastStruct]), + ClusterObjectFieldDescriptor(Label="optOutState", Tag=0x00000007, Type=typing.Optional[DeviceEnergyManagement.Enums.OptOutStateEnum]), ClusterObjectFieldDescriptor(Label="generatedCommandList", Tag=0x0000FFF8, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="acceptedCommandList", Tag=0x0000FFF9, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="eventList", Tag=0x0000FFFA, Type=typing.List[uint]), @@ -23386,6 +23387,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: absMaxPower: 'int' = None powerAdjustmentCapability: 'typing.Union[None, Nullable, typing.List[DeviceEnergyManagement.Structs.PowerAdjustStruct]]' = None forecast: 'typing.Union[None, Nullable, DeviceEnergyManagement.Structs.ForecastStruct]' = None + optOutState: 'typing.Optional[DeviceEnergyManagement.Enums.OptOutStateEnum]' = None generatedCommandList: 'typing.List[uint]' = None acceptedCommandList: 'typing.List[uint]' = None eventList: 'typing.List[uint]' = None @@ -23394,16 +23396,26 @@ def descriptor(cls) -> ClusterObjectDescriptor: clusterRevision: 'uint' = None class Enums: + class AdjustmentCauseEnum(MatterIntEnum): + kLocalOptimization = 0x00 + kGridOptimization = 0x01 + # All received enum values that are not listed above will be mapped + # to kUnknownEnumValue. This is a helper enum value that should only + # be used by code to process how it handles receiving and unknown + # enum value. This specific should never be transmitted. + kUnknownEnumValue = 2, + class CauseEnum(MatterIntEnum): kNormalCompletion = 0x00 kOffline = 0x01 kFault = 0x02 kUserOptOut = 0x03 + kCancelled = 0x04 # All received enum values that are not listed above will be mapped # to kUnknownEnumValue. This is a helper enum value that should only # be used by code to process how it handles receiving and unknown # enum value. This specific should never be transmitted. - kUnknownEnumValue = 4, + kUnknownEnumValue = 5, class CostTypeEnum(MatterIntEnum): kFinancial = 0x00 @@ -23420,14 +23432,13 @@ class ESAStateEnum(MatterIntEnum): kOffline = 0x00 kOnline = 0x01 kFault = 0x02 - kUserOptOut = 0x03 - kPowerAdjustActive = 0x04 - kPaused = 0x05 + kPowerAdjustActive = 0x03 + kPaused = 0x04 # All received enum values that are not listed above will be mapped # to kUnknownEnumValue. This is a helper enum value that should only # be used by code to process how it handles receiving and unknown # enum value. This specific should never be transmitted. - kUnknownEnumValue = 6, + kUnknownEnumValue = 5, class ESATypeEnum(MatterIntEnum): kEvse = 0x00 @@ -23451,12 +23462,36 @@ class ESATypeEnum(MatterIntEnum): # enum value. This specific should never be transmitted. kUnknownEnumValue = 14, + class ForecastUpdateReasonEnum(MatterIntEnum): + kInternalOptimization = 0x00 + kLocalOptimization = 0x01 + kGridOptimization = 0x02 + # All received enum values that are not listed above will be mapped + # to kUnknownEnumValue. This is a helper enum value that should only + # be used by code to process how it handles receiving and unknown + # enum value. This specific should never be transmitted. + kUnknownEnumValue = 3, + + class OptOutStateEnum(MatterIntEnum): + kNoOptOut = 0x00 + kLocalOptOut = 0x01 + kGridOptOut = 0x02 + kOptOut = 0x03 + # All received enum values that are not listed above will be mapped + # to kUnknownEnumValue. This is a helper enum value that should only + # be used by code to process how it handles receiving and unknown + # enum value. This specific should never be transmitted. + kUnknownEnumValue = 4, + class Bitmaps: class Feature(IntFlag): kPowerAdjustment = 0x1 kPowerForecastReporting = 0x2 kStateForecastReporting = 0x4 - kForecastAdjustment = 0x8 + kStartTimeAdjustment = 0x8 + kPausable = 0x10 + kForecastAdjustment = 0x20 + kConstraintBasedAdjustment = 0x40 class Structs: @dataclass @@ -23487,9 +23522,9 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="defaultDuration", Tag=2, Type=uint), ClusterObjectFieldDescriptor(Label="elapsedSlotTime", Tag=3, Type=uint), ClusterObjectFieldDescriptor(Label="remainingSlotTime", Tag=4, Type=uint), - ClusterObjectFieldDescriptor(Label="slotIsPauseable", Tag=5, Type=bool), - ClusterObjectFieldDescriptor(Label="minPauseDuration", Tag=6, Type=uint), - ClusterObjectFieldDescriptor(Label="maxPauseDuration", Tag=7, Type=uint), + ClusterObjectFieldDescriptor(Label="slotIsPauseable", Tag=5, Type=typing.Optional[bool]), + ClusterObjectFieldDescriptor(Label="minPauseDuration", Tag=6, Type=typing.Optional[uint]), + ClusterObjectFieldDescriptor(Label="maxPauseDuration", Tag=7, Type=typing.Optional[uint]), ClusterObjectFieldDescriptor(Label="manufacturerESAState", Tag=8, Type=typing.Optional[uint]), ClusterObjectFieldDescriptor(Label="nominalPower", Tag=9, Type=typing.Optional[int]), ClusterObjectFieldDescriptor(Label="minPower", Tag=10, Type=typing.Optional[int]), @@ -23507,9 +23542,9 @@ def descriptor(cls) -> ClusterObjectDescriptor: defaultDuration: 'uint' = 0 elapsedSlotTime: 'uint' = 0 remainingSlotTime: 'uint' = 0 - slotIsPauseable: 'bool' = False - minPauseDuration: 'uint' = 0 - maxPauseDuration: 'uint' = 0 + slotIsPauseable: 'typing.Optional[bool]' = None + minPauseDuration: 'typing.Optional[uint]' = None + maxPauseDuration: 'typing.Optional[uint]' = None manufacturerESAState: 'typing.Optional[uint]' = None nominalPower: 'typing.Optional[int]' = None minPower: 'typing.Optional[int]' = None @@ -23535,6 +23570,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="latestEndTime", Tag=5, Type=typing.Optional[uint]), ClusterObjectFieldDescriptor(Label="isPauseable", Tag=6, Type=bool), ClusterObjectFieldDescriptor(Label="slots", Tag=7, Type=typing.List[DeviceEnergyManagement.Structs.SlotStruct]), + ClusterObjectFieldDescriptor(Label="forecastUpdateReason", Tag=8, Type=DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum), ]) forecastId: 'uint' = 0 @@ -23545,6 +23581,7 @@ def descriptor(cls) -> ClusterObjectDescriptor: latestEndTime: 'typing.Optional[uint]' = None isPauseable: 'bool' = False slots: 'typing.List[DeviceEnergyManagement.Structs.SlotStruct]' = field(default_factory=lambda: []) + forecastUpdateReason: 'DeviceEnergyManagement.Enums.ForecastUpdateReasonEnum' = 0 @dataclass class ConstraintsStruct(ClusterObject): @@ -23611,10 +23648,12 @@ def descriptor(cls) -> ClusterObjectDescriptor: Fields=[ ClusterObjectFieldDescriptor(Label="power", Tag=0, Type=int), ClusterObjectFieldDescriptor(Label="duration", Tag=1, Type=uint), + ClusterObjectFieldDescriptor(Label="cause", Tag=2, Type=DeviceEnergyManagement.Enums.AdjustmentCauseEnum), ]) power: 'int' = 0 duration: 'uint' = 0 + cause: 'DeviceEnergyManagement.Enums.AdjustmentCauseEnum' = 0 @dataclass class CancelPowerAdjustRequest(ClusterCommand): @@ -23641,9 +23680,11 @@ def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ ClusterObjectFieldDescriptor(Label="requestedStartTime", Tag=0, Type=uint), + ClusterObjectFieldDescriptor(Label="cause", Tag=1, Type=DeviceEnergyManagement.Enums.AdjustmentCauseEnum), ]) requestedStartTime: 'uint' = 0 + cause: 'DeviceEnergyManagement.Enums.AdjustmentCauseEnum' = 0 @dataclass class PauseRequest(ClusterCommand): @@ -23657,9 +23698,11 @@ def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ ClusterObjectFieldDescriptor(Label="duration", Tag=0, Type=uint), + ClusterObjectFieldDescriptor(Label="cause", Tag=1, Type=DeviceEnergyManagement.Enums.AdjustmentCauseEnum), ]) duration: 'uint' = 0 + cause: 'DeviceEnergyManagement.Enums.AdjustmentCauseEnum' = 0 @dataclass class ResumeRequest(ClusterCommand): @@ -23687,10 +23730,12 @@ def descriptor(cls) -> ClusterObjectDescriptor: Fields=[ ClusterObjectFieldDescriptor(Label="forecastId", Tag=0, Type=uint), ClusterObjectFieldDescriptor(Label="slotAdjustments", Tag=1, Type=typing.List[DeviceEnergyManagement.Structs.SlotAdjustmentStruct]), + ClusterObjectFieldDescriptor(Label="cause", Tag=2, Type=DeviceEnergyManagement.Enums.AdjustmentCauseEnum), ]) forecastId: 'uint' = 0 slotAdjustments: 'typing.List[DeviceEnergyManagement.Structs.SlotAdjustmentStruct]' = field(default_factory=lambda: []) + cause: 'DeviceEnergyManagement.Enums.AdjustmentCauseEnum' = 0 @dataclass class RequestConstraintBasedForecast(ClusterCommand): @@ -23704,9 +23749,24 @@ def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ ClusterObjectFieldDescriptor(Label="constraints", Tag=0, Type=typing.List[DeviceEnergyManagement.Structs.ConstraintsStruct]), + ClusterObjectFieldDescriptor(Label="cause", Tag=1, Type=DeviceEnergyManagement.Enums.AdjustmentCauseEnum), ]) constraints: 'typing.List[DeviceEnergyManagement.Structs.ConstraintsStruct]' = field(default_factory=lambda: []) + cause: 'DeviceEnergyManagement.Enums.AdjustmentCauseEnum' = 0 + + @dataclass + class CancelRequest(ClusterCommand): + cluster_id: typing.ClassVar[int] = 0x00000098 + command_id: typing.ClassVar[int] = 0x00000007 + is_client: typing.ClassVar[bool] = True + response_type: typing.ClassVar[str] = None + + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields=[ + ]) class Attributes: @dataclass @@ -23821,6 +23881,22 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor: value: 'typing.Union[None, Nullable, DeviceEnergyManagement.Structs.ForecastStruct]' = None + @dataclass + class OptOutState(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x00000098 + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000007 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Optional[DeviceEnergyManagement.Enums.OptOutStateEnum]) + + value: 'typing.Optional[DeviceEnergyManagement.Enums.OptOutStateEnum]' = None + @dataclass class GeneratedCommandList(ClusterAttributeDescriptor): @ChipUtility.classproperty @@ -23987,8 +24063,11 @@ def event_id(cls) -> int: def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields=[ + ClusterObjectFieldDescriptor(Label="cause", Tag=0, Type=DeviceEnergyManagement.Enums.CauseEnum), ]) + cause: 'DeviceEnergyManagement.Enums.CauseEnum' = 0 + @dataclass class EnergyEvse(Cluster): diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm index d7d9849a4f9c57..a63147b8a9eedf 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeSpecifiedCheck.mm @@ -3063,6 +3063,9 @@ static BOOL AttributeIsSpecifiedInDeviceEnergyManagementCluster(AttributeId aAtt case Attributes::Forecast::Id: { return YES; } + case Attributes::OptOutState::Id: { + return YES; + } case Attributes::GeneratedCommandList::Id: { return YES; } diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm index acf77070414712..eb5827496fc0d5 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRAttributeTLVValueDecoder.mm @@ -8446,9 +8446,21 @@ static id _Nullable DecodeAttributeValueForDeviceEnergyManagementCluster(Attribu newElement_2.defaultDuration = [NSNumber numberWithUnsignedInt:entry_2.defaultDuration]; newElement_2.elapsedSlotTime = [NSNumber numberWithUnsignedInt:entry_2.elapsedSlotTime]; newElement_2.remainingSlotTime = [NSNumber numberWithUnsignedInt:entry_2.remainingSlotTime]; - newElement_2.slotIsPauseable = [NSNumber numberWithBool:entry_2.slotIsPauseable]; - newElement_2.minPauseDuration = [NSNumber numberWithUnsignedInt:entry_2.minPauseDuration]; - newElement_2.maxPauseDuration = [NSNumber numberWithUnsignedInt:entry_2.maxPauseDuration]; + if (entry_2.slotIsPauseable.HasValue()) { + newElement_2.slotIsPauseable = [NSNumber numberWithBool:entry_2.slotIsPauseable.Value()]; + } else { + newElement_2.slotIsPauseable = nil; + } + if (entry_2.minPauseDuration.HasValue()) { + newElement_2.minPauseDuration = [NSNumber numberWithUnsignedInt:entry_2.minPauseDuration.Value()]; + } else { + newElement_2.minPauseDuration = nil; + } + if (entry_2.maxPauseDuration.HasValue()) { + newElement_2.maxPauseDuration = [NSNumber numberWithUnsignedInt:entry_2.maxPauseDuration.Value()]; + } else { + newElement_2.maxPauseDuration = nil; + } if (entry_2.manufacturerESAState.HasValue()) { newElement_2.manufacturerESAState = [NSNumber numberWithUnsignedShort:entry_2.manufacturerESAState.Value()]; } else { @@ -8531,9 +8543,21 @@ static id _Nullable DecodeAttributeValueForDeviceEnergyManagementCluster(Attribu } value.slots = array_2; } + value.forecastUpdateReason = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue.Value().forecastUpdateReason)]; } return value; } + case Attributes::OptOutState::Id: { + using TypeInfo = Attributes::OptOutState::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nonnull value; + value = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue)]; + return value; + } default: { break; } diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h index f484ada4d19774..f30370c30b409a 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.h @@ -7591,6 +7591,14 @@ MTR_PROVISIONALLY_AVAILABLE * Allows a client to ask the ESA to recompute its Forecast based on power and time constraints. */ - (void)requestConstraintBasedForecastWithParams:(MTRDeviceEnergyManagementClusterRequestConstraintBasedForecastParams *)params completion:(MTRStatusCompletion)completion MTR_PROVISIONALLY_AVAILABLE; +/** + * Command CancelRequest + * + * Allows a client to request cancellation of a previous adjustment request in a StartTimeAdjustRequest, ModifyForecastRequest or RequestConstraintBasedForecast command + */ +- (void)cancelRequestWithParams:(MTRDeviceEnergyManagementClusterCancelRequestParams * _Nullable)params completion:(MTRStatusCompletion)completion MTR_PROVISIONALLY_AVAILABLE; +- (void)cancelRequestWithCompletion:(MTRStatusCompletion)completion + MTR_PROVISIONALLY_AVAILABLE; - (void)readAttributeESATypeWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; - (void)subscribeAttributeESATypeWithParams:(MTRSubscribeParams *)params @@ -7634,6 +7642,12 @@ MTR_PROVISIONALLY_AVAILABLE reportHandler:(void (^)(MTRDeviceEnergyManagementClusterForecastStruct * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; + (void)readAttributeForecastWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(MTRDeviceEnergyManagementClusterForecastStruct * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)readAttributeOptOutStateWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; +- (void)subscribeAttributeOptOutStateWithParams:(MTRSubscribeParams *)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler MTR_PROVISIONALLY_AVAILABLE; ++ (void)readAttributeOptOutStateWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; + - (void)readAttributeGeneratedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion MTR_PROVISIONALLY_AVAILABLE; - (void)subscribeAttributeGeneratedCommandListWithParams:(MTRSubscribeParams *)params subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished @@ -17357,11 +17371,17 @@ typedef NS_OPTIONS(uint32_t, MTRDemandResponseLoadControlFeature) { MTRDemandResponseLoadControlFeatureHeatingSource MTR_PROVISIONALLY_AVAILABLE = 0x40, } MTR_PROVISIONALLY_AVAILABLE; +typedef NS_ENUM(uint8_t, MTRDeviceEnergyManagementAdjustmentCause) { + MTRDeviceEnergyManagementAdjustmentCauseLocalOptimization MTR_PROVISIONALLY_AVAILABLE = 0x00, + MTRDeviceEnergyManagementAdjustmentCauseGridOptimization MTR_PROVISIONALLY_AVAILABLE = 0x01, +} MTR_PROVISIONALLY_AVAILABLE; + typedef NS_ENUM(uint8_t, MTRDeviceEnergyManagementCause) { MTRDeviceEnergyManagementCauseNormalCompletion MTR_PROVISIONALLY_AVAILABLE = 0x00, MTRDeviceEnergyManagementCauseOffline MTR_PROVISIONALLY_AVAILABLE = 0x01, MTRDeviceEnergyManagementCauseFault MTR_PROVISIONALLY_AVAILABLE = 0x02, MTRDeviceEnergyManagementCauseUserOptOut MTR_PROVISIONALLY_AVAILABLE = 0x03, + MTRDeviceEnergyManagementCauseCancelled MTR_PROVISIONALLY_AVAILABLE = 0x04, } MTR_PROVISIONALLY_AVAILABLE; typedef NS_ENUM(uint8_t, MTRDeviceEnergyManagementCostType) { @@ -17375,9 +17395,8 @@ typedef NS_ENUM(uint8_t, MTRDeviceEnergyManagementESAState) { MTRDeviceEnergyManagementESAStateOffline MTR_PROVISIONALLY_AVAILABLE = 0x00, MTRDeviceEnergyManagementESAStateOnline MTR_PROVISIONALLY_AVAILABLE = 0x01, MTRDeviceEnergyManagementESAStateFault MTR_PROVISIONALLY_AVAILABLE = 0x02, - MTRDeviceEnergyManagementESAStateUserOptOut MTR_PROVISIONALLY_AVAILABLE = 0x03, - MTRDeviceEnergyManagementESAStatePowerAdjustActive MTR_PROVISIONALLY_AVAILABLE = 0x04, - MTRDeviceEnergyManagementESAStatePaused MTR_PROVISIONALLY_AVAILABLE = 0x05, + MTRDeviceEnergyManagementESAStatePowerAdjustActive MTR_PROVISIONALLY_AVAILABLE = 0x03, + MTRDeviceEnergyManagementESAStatePaused MTR_PROVISIONALLY_AVAILABLE = 0x04, } MTR_PROVISIONALLY_AVAILABLE; typedef NS_ENUM(uint8_t, MTRDeviceEnergyManagementESAType) { @@ -17398,11 +17417,27 @@ typedef NS_ENUM(uint8_t, MTRDeviceEnergyManagementESAType) { MTRDeviceEnergyManagementESATypeOther MTR_PROVISIONALLY_AVAILABLE = 0xFF, } MTR_PROVISIONALLY_AVAILABLE; +typedef NS_ENUM(uint8_t, MTRDeviceEnergyManagementForecastUpdateReason) { + MTRDeviceEnergyManagementForecastUpdateReasonInternalOptimization MTR_PROVISIONALLY_AVAILABLE = 0x00, + MTRDeviceEnergyManagementForecastUpdateReasonLocalOptimization MTR_PROVISIONALLY_AVAILABLE = 0x01, + MTRDeviceEnergyManagementForecastUpdateReasonGridOptimization MTR_PROVISIONALLY_AVAILABLE = 0x02, +} MTR_PROVISIONALLY_AVAILABLE; + +typedef NS_ENUM(uint8_t, MTRDeviceEnergyManagementOptOutState) { + MTRDeviceEnergyManagementOptOutStateNoOptOut MTR_PROVISIONALLY_AVAILABLE = 0x00, + MTRDeviceEnergyManagementOptOutStateLocalOptOut MTR_PROVISIONALLY_AVAILABLE = 0x01, + MTRDeviceEnergyManagementOptOutStateGridOptOut MTR_PROVISIONALLY_AVAILABLE = 0x02, + MTRDeviceEnergyManagementOptOutStateOptOut MTR_PROVISIONALLY_AVAILABLE = 0x03, +} MTR_PROVISIONALLY_AVAILABLE; + typedef NS_OPTIONS(uint32_t, MTRDeviceEnergyManagementFeature) { MTRDeviceEnergyManagementFeaturePowerAdjustment MTR_PROVISIONALLY_AVAILABLE = 0x1, MTRDeviceEnergyManagementFeaturePowerForecastReporting MTR_PROVISIONALLY_AVAILABLE = 0x2, MTRDeviceEnergyManagementFeatureStateForecastReporting MTR_PROVISIONALLY_AVAILABLE = 0x4, - MTRDeviceEnergyManagementFeatureForecastAdjustment MTR_PROVISIONALLY_AVAILABLE = 0x8, + MTRDeviceEnergyManagementFeatureStartTimeAdjustment MTR_PROVISIONALLY_AVAILABLE = 0x8, + MTRDeviceEnergyManagementFeaturePausable MTR_PROVISIONALLY_AVAILABLE = 0x10, + MTRDeviceEnergyManagementFeatureForecastAdjustment MTR_PROVISIONALLY_AVAILABLE = 0x20, + MTRDeviceEnergyManagementFeatureConstraintBasedAdjustment MTR_PROVISIONALLY_AVAILABLE = 0x40, } MTR_PROVISIONALLY_AVAILABLE; typedef NS_ENUM(uint8_t, MTREnergyEVSEEnergyTransferStoppedReason) { diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm index aa248a596e44b3..2b8f1dbfc61eec 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRBaseClusters.mm @@ -51414,6 +51414,34 @@ - (void)requestConstraintBasedForecastWithParams:(MTRDeviceEnergyManagementClust queue:self.callbackQueue completion:responseHandler]; } +- (void)cancelRequestWithCompletion:(MTRStatusCompletion)completion +{ + [self cancelRequestWithParams:nil completion:completion]; +} +- (void)cancelRequestWithParams:(MTRDeviceEnergyManagementClusterCancelRequestParams * _Nullable)params completion:(MTRStatusCompletion)completion +{ + if (params == nil) { + params = [[MTRDeviceEnergyManagementClusterCancelRequestParams + alloc] init]; + } + + auto responseHandler = ^(id _Nullable response, NSError * _Nullable error) { + completion(error); + }; + + auto * timedInvokeTimeoutMs = params.timedInvokeTimeoutMs; + + using RequestType = DeviceEnergyManagement::Commands::CancelRequest::Type; + [self.device _invokeKnownCommandWithEndpointID:@(self.endpoint) + clusterID:@(RequestType::GetClusterId()) + commandID:@(RequestType::GetCommandId()) + commandPayload:params + timedInvokeTimeout:timedInvokeTimeoutMs + serverSideProcessingTimeout:params.serverSideProcessingTimeout + responseClass:nil + queue:self.callbackQueue + completion:responseHandler]; +} - (void)readAttributeESATypeWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion { @@ -51667,6 +51695,42 @@ + (void)readAttributeForecastWithClusterStateCache:(MTRClusterStateCacheContaine completion:completion]; } +- (void)readAttributeOptOutStateWithCompletion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = DeviceEnergyManagement::Attributes::OptOutState::TypeInfo; + [self.device _readKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:nil + queue:self.callbackQueue + completion:completion]; +} + +- (void)subscribeAttributeOptOutStateWithParams:(MTRSubscribeParams * _Nonnull)params + subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + using TypeInfo = DeviceEnergyManagement::Attributes::OptOutState::TypeInfo; + [self.device _subscribeToKnownAttributeWithEndpointID:@(self.endpoint) + clusterID:@(TypeInfo::GetClusterId()) + attributeID:@(TypeInfo::GetAttributeId()) + params:params + queue:self.callbackQueue + reportHandler:reportHandler + subscriptionEstablished:subscriptionEstablished]; +} + ++ (void)readAttributeOptOutStateWithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completion +{ + using TypeInfo = DeviceEnergyManagement::Attributes::OptOutState::TypeInfo; + [clusterStateCacheContainer + _readKnownCachedAttributeWithEndpointID:static_cast([endpoint unsignedShortValue]) + clusterID:TypeInfo::GetClusterId() + attributeID:TypeInfo::GetAttributeId() + queue:queue + completion:completion]; +} + - (void)readAttributeGeneratedCommandListWithCompletion:(void (^)(NSArray * _Nullable value, NSError * _Nullable error))completion { using TypeInfo = DeviceEnergyManagement::Attributes::GeneratedCommandList::TypeInfo; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h index fedd4aa13d0628..f598a052c31fb4 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusterConstants.h @@ -2618,6 +2618,7 @@ typedef NS_ENUM(uint32_t, MTRAttributeIDType) { MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeAbsMaxPowerID MTR_PROVISIONALLY_AVAILABLE = 0x00000004, MTRAttributeIDTypeClusterDeviceEnergyManagementAttributePowerAdjustmentCapabilityID MTR_PROVISIONALLY_AVAILABLE = 0x00000005, MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeForecastID MTR_PROVISIONALLY_AVAILABLE = 0x00000006, + MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeOptOutStateID MTR_PROVISIONALLY_AVAILABLE = 0x00000007, MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeGeneratedCommandListID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeGeneratedCommandListID, MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeAcceptedCommandListID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeAcceptedCommandListID, MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeEventListID MTR_PROVISIONALLY_AVAILABLE = MTRAttributeIDTypeGlobalAttributeEventListID, @@ -6220,6 +6221,7 @@ typedef NS_ENUM(uint32_t, MTRCommandIDType) { MTRCommandIDTypeClusterDeviceEnergyManagementCommandResumeRequestID MTR_PROVISIONALLY_AVAILABLE = 0x00000004, MTRCommandIDTypeClusterDeviceEnergyManagementCommandModifyForecastRequestID MTR_PROVISIONALLY_AVAILABLE = 0x00000005, MTRCommandIDTypeClusterDeviceEnergyManagementCommandRequestConstraintBasedForecastID MTR_PROVISIONALLY_AVAILABLE = 0x00000006, + MTRCommandIDTypeClusterDeviceEnergyManagementCommandCancelRequestID MTR_PROVISIONALLY_AVAILABLE = 0x00000007, // Cluster EnergyEVSE commands MTRCommandIDTypeClusterEnergyEVSECommandGetTargetsResponseID MTR_PROVISIONALLY_AVAILABLE = 0x00000000, diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h index a102f158d5b0a4..38d6ca3aba518e 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.h @@ -3583,6 +3583,9 @@ MTR_PROVISIONALLY_AVAILABLE MTR_PROVISIONALLY_AVAILABLE; - (void)modifyForecastRequestWithParams:(MTRDeviceEnergyManagementClusterModifyForecastRequestParams *)params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(MTRStatusCompletion)completion MTR_PROVISIONALLY_AVAILABLE; - (void)requestConstraintBasedForecastWithParams:(MTRDeviceEnergyManagementClusterRequestConstraintBasedForecastParams *)params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(MTRStatusCompletion)completion MTR_PROVISIONALLY_AVAILABLE; +- (void)cancelRequestWithParams:(MTRDeviceEnergyManagementClusterCancelRequestParams * _Nullable)params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(MTRStatusCompletion)completion MTR_PROVISIONALLY_AVAILABLE; +- (void)cancelRequestWithExpectedValues:(NSArray *> * _Nullable)expectedValues expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(MTRStatusCompletion)completion + MTR_PROVISIONALLY_AVAILABLE; - (NSDictionary * _Nullable)readAttributeESATypeWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; @@ -3598,6 +3601,8 @@ MTR_PROVISIONALLY_AVAILABLE - (NSDictionary * _Nullable)readAttributeForecastWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; +- (NSDictionary * _Nullable)readAttributeOptOutStateWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; + - (NSDictionary * _Nullable)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; - (NSDictionary * _Nullable)readAttributeAcceptedCommandListWithParams:(MTRReadParams * _Nullable)params MTR_PROVISIONALLY_AVAILABLE; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm index 11ca8e1ab2e8eb..b9373e99317821 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm @@ -9735,6 +9735,37 @@ - (void)requestConstraintBasedForecastWithParams:(MTRDeviceEnergyManagementClust completion:responseHandler]; } +- (void)cancelRequestWithExpectedValues:(NSArray *> *)expectedValues expectedValueInterval:(NSNumber *)expectedValueIntervalMs completion:(MTRStatusCompletion)completion +{ + [self cancelRequestWithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completion:completion]; +} +- (void)cancelRequestWithParams:(MTRDeviceEnergyManagementClusterCancelRequestParams * _Nullable)params expectedValues:(NSArray *> * _Nullable)expectedValues expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:(MTRStatusCompletion)completion +{ + if (params == nil) { + params = [[MTRDeviceEnergyManagementClusterCancelRequestParams + alloc] init]; + } + + auto responseHandler = ^(id _Nullable response, NSError * _Nullable error) { + completion(error); + }; + + auto * timedInvokeTimeoutMs = params.timedInvokeTimeoutMs; + + using RequestType = DeviceEnergyManagement::Commands::CancelRequest::Type; + [self.device _invokeKnownCommandWithEndpointID:@(self.endpoint) + clusterID:@(RequestType::GetClusterId()) + commandID:@(RequestType::GetCommandId()) + commandPayload:params + expectedValues:expectedValues + expectedValueInterval:expectedValueIntervalMs + timedInvokeTimeout:timedInvokeTimeoutMs + serverSideProcessingTimeout:params.serverSideProcessingTimeout + responseClass:nil + queue:self.callbackQueue + completion:responseHandler]; +} + - (NSDictionary * _Nullable)readAttributeESATypeWithParams:(MTRReadParams * _Nullable)params { return [self.device readAttributeWithEndpointID:@(self.endpoint) clusterID:@(MTRClusterIDTypeDeviceEnergyManagementID) attributeID:@(MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeESATypeID) params:params]; @@ -9770,6 +9801,11 @@ - (void)requestConstraintBasedForecastWithParams:(MTRDeviceEnergyManagementClust return [self.device readAttributeWithEndpointID:@(self.endpoint) clusterID:@(MTRClusterIDTypeDeviceEnergyManagementID) attributeID:@(MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeForecastID) params:params]; } +- (NSDictionary * _Nullable)readAttributeOptOutStateWithParams:(MTRReadParams * _Nullable)params +{ + return [self.device readAttributeWithEndpointID:@(self.endpoint) clusterID:@(MTRClusterIDTypeDeviceEnergyManagementID) attributeID:@(MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeOptOutStateID) params:params]; +} + - (NSDictionary * _Nullable)readAttributeGeneratedCommandListWithParams:(MTRReadParams * _Nullable)params { return [self.device readAttributeWithEndpointID:@(self.endpoint) clusterID:@(MTRClusterIDTypeDeviceEnergyManagementID) attributeID:@(MTRAttributeIDTypeClusterDeviceEnergyManagementAttributeGeneratedCommandListID) params:params]; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h index 1656beb4969d85..968322f3f3ff47 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.h @@ -5639,6 +5639,8 @@ MTR_PROVISIONALLY_AVAILABLE @property (nonatomic, copy) NSNumber * _Nonnull power MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nonnull duration MTR_PROVISIONALLY_AVAILABLE; + +@property (nonatomic, copy) NSNumber * _Nonnull cause MTR_PROVISIONALLY_AVAILABLE; /** * Controls whether the command is a timed command (using Timed Invoke). * @@ -5697,6 +5699,8 @@ MTR_PROVISIONALLY_AVAILABLE @interface MTRDeviceEnergyManagementClusterStartTimeAdjustRequestParams : NSObject @property (nonatomic, copy) NSNumber * _Nonnull requestedStartTime MTR_PROVISIONALLY_AVAILABLE; + +@property (nonatomic, copy) NSNumber * _Nonnull cause MTR_PROVISIONALLY_AVAILABLE; /** * Controls whether the command is a timed command (using Timed Invoke). * @@ -5727,6 +5731,8 @@ MTR_PROVISIONALLY_AVAILABLE @interface MTRDeviceEnergyManagementClusterPauseRequestParams : NSObject @property (nonatomic, copy) NSNumber * _Nonnull duration MTR_PROVISIONALLY_AVAILABLE; + +@property (nonatomic, copy) NSNumber * _Nonnull cause MTR_PROVISIONALLY_AVAILABLE; /** * Controls whether the command is a timed command (using Timed Invoke). * @@ -5787,6 +5793,8 @@ MTR_PROVISIONALLY_AVAILABLE @property (nonatomic, copy) NSNumber * _Nonnull forecastId MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSArray * _Nonnull slotAdjustments MTR_PROVISIONALLY_AVAILABLE; + +@property (nonatomic, copy) NSNumber * _Nonnull cause MTR_PROVISIONALLY_AVAILABLE; /** * Controls whether the command is a timed command (using Timed Invoke). * @@ -5817,6 +5825,36 @@ MTR_PROVISIONALLY_AVAILABLE @interface MTRDeviceEnergyManagementClusterRequestConstraintBasedForecastParams : NSObject @property (nonatomic, copy) NSArray * _Nonnull constraints MTR_PROVISIONALLY_AVAILABLE; + +@property (nonatomic, copy) NSNumber * _Nonnull cause MTR_PROVISIONALLY_AVAILABLE; +/** + * Controls whether the command is a timed command (using Timed Invoke). + * + * If nil (the default value), a regular invoke is done for commands that do + * not require a timed invoke and a timed invoke with some default timed request + * timeout is done for commands that require a timed invoke. + * + * If not nil, a timed invoke is done, with the provided value used as the timed + * request timeout. The value should be chosen small enough to provide the + * desired security properties but large enough that it will allow a round-trip + * from the sever to the client (for the status response and actual invoke + * request) within the timeout window. + * + */ +@property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs; + +/** + * Controls how much time, in seconds, we will allow for the server to process the command. + * + * The command will then time out if that much time, plus an allowance for retransmits due to network failures, passes. + * + * If nil, the framework will try to select an appropriate timeout value itself. + */ +@property (nonatomic, copy, nullable) NSNumber * serverSideProcessingTimeout; +@end + +MTR_PROVISIONALLY_AVAILABLE +@interface MTRDeviceEnergyManagementClusterCancelRequestParams : NSObject /** * Controls whether the command is a timed command (using Timed Invoke). * diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm index a1e41d3407a968..e19b1ee4477e4d 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloadsObjc.mm @@ -15903,6 +15903,8 @@ - (instancetype)init _power = @(0); _duration = @(0); + + _cause = @(0); _timedInvokeTimeoutMs = nil; _serverSideProcessingTimeout = nil; } @@ -15915,6 +15917,7 @@ - (id)copyWithZone:(NSZone * _Nullable)zone; other.power = self.power; other.duration = self.duration; + other.cause = self.cause; other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs; other.serverSideProcessingTimeout = self.serverSideProcessingTimeout; @@ -15923,7 +15926,7 @@ - (id)copyWithZone:(NSZone * _Nullable)zone; - (NSString *)description { - NSString * descriptionString = [NSString stringWithFormat:@"<%@: power:%@; duration:%@; >", NSStringFromClass([self class]), _power, _duration]; + NSString * descriptionString = [NSString stringWithFormat:@"<%@: power:%@; duration:%@; cause:%@; >", NSStringFromClass([self class]), _power, _duration, _cause]; return descriptionString; } @@ -15941,6 +15944,9 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader { encodableStruct.duration = self.duration.unsignedIntValue; } + { + encodableStruct.cause = static_cast>(self.cause.unsignedCharValue); + } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); if (buffer.IsNull()) { @@ -16059,6 +16065,8 @@ - (instancetype)init if (self = [super init]) { _requestedStartTime = @(0); + + _cause = @(0); _timedInvokeTimeoutMs = nil; _serverSideProcessingTimeout = nil; } @@ -16070,6 +16078,7 @@ - (id)copyWithZone:(NSZone * _Nullable)zone; auto other = [[MTRDeviceEnergyManagementClusterStartTimeAdjustRequestParams alloc] init]; other.requestedStartTime = self.requestedStartTime; + other.cause = self.cause; other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs; other.serverSideProcessingTimeout = self.serverSideProcessingTimeout; @@ -16078,7 +16087,7 @@ - (id)copyWithZone:(NSZone * _Nullable)zone; - (NSString *)description { - NSString * descriptionString = [NSString stringWithFormat:@"<%@: requestedStartTime:%@; >", NSStringFromClass([self class]), _requestedStartTime]; + NSString * descriptionString = [NSString stringWithFormat:@"<%@: requestedStartTime:%@; cause:%@; >", NSStringFromClass([self class]), _requestedStartTime, _cause]; return descriptionString; } @@ -16093,6 +16102,9 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader { encodableStruct.requestedStartTime = self.requestedStartTime.unsignedIntValue; } + { + encodableStruct.cause = static_cast>(self.cause.unsignedCharValue); + } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); if (buffer.IsNull()) { @@ -16138,6 +16150,8 @@ - (instancetype)init if (self = [super init]) { _duration = @(0); + + _cause = @(0); _timedInvokeTimeoutMs = nil; _serverSideProcessingTimeout = nil; } @@ -16149,6 +16163,7 @@ - (id)copyWithZone:(NSZone * _Nullable)zone; auto other = [[MTRDeviceEnergyManagementClusterPauseRequestParams alloc] init]; other.duration = self.duration; + other.cause = self.cause; other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs; other.serverSideProcessingTimeout = self.serverSideProcessingTimeout; @@ -16157,7 +16172,7 @@ - (id)copyWithZone:(NSZone * _Nullable)zone; - (NSString *)description { - NSString * descriptionString = [NSString stringWithFormat:@"<%@: duration:%@; >", NSStringFromClass([self class]), _duration]; + NSString * descriptionString = [NSString stringWithFormat:@"<%@: duration:%@; cause:%@; >", NSStringFromClass([self class]), _duration, _cause]; return descriptionString; } @@ -16172,6 +16187,9 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader { encodableStruct.duration = self.duration.unsignedIntValue; } + { + encodableStruct.cause = static_cast>(self.cause.unsignedCharValue); + } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); if (buffer.IsNull()) { @@ -16292,6 +16310,8 @@ - (instancetype)init _forecastId = @(0); _slotAdjustments = [NSArray array]; + + _cause = @(0); _timedInvokeTimeoutMs = nil; _serverSideProcessingTimeout = nil; } @@ -16304,6 +16324,7 @@ - (id)copyWithZone:(NSZone * _Nullable)zone; other.forecastId = self.forecastId; other.slotAdjustments = self.slotAdjustments; + other.cause = self.cause; other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs; other.serverSideProcessingTimeout = self.serverSideProcessingTimeout; @@ -16312,7 +16333,7 @@ - (id)copyWithZone:(NSZone * _Nullable)zone; - (NSString *)description { - NSString * descriptionString = [NSString stringWithFormat:@"<%@: forecastId:%@; slotAdjustments:%@; >", NSStringFromClass([self class]), _forecastId, _slotAdjustments]; + NSString * descriptionString = [NSString stringWithFormat:@"<%@: forecastId:%@; slotAdjustments:%@; cause:%@; >", NSStringFromClass([self class]), _forecastId, _slotAdjustments, _cause]; return descriptionString; } @@ -16353,6 +16374,9 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader } } } + { + encodableStruct.cause = static_cast>(self.cause.unsignedCharValue); + } auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); if (buffer.IsNull()) { @@ -16398,6 +16422,8 @@ - (instancetype)init if (self = [super init]) { _constraints = [NSArray array]; + + _cause = @(0); _timedInvokeTimeoutMs = nil; _serverSideProcessingTimeout = nil; } @@ -16409,6 +16435,7 @@ - (id)copyWithZone:(NSZone * _Nullable)zone; auto other = [[MTRDeviceEnergyManagementClusterRequestConstraintBasedForecastParams alloc] init]; other.constraints = self.constraints; + other.cause = self.cause; other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs; other.serverSideProcessingTimeout = self.serverSideProcessingTimeout; @@ -16417,7 +16444,7 @@ - (id)copyWithZone:(NSZone * _Nullable)zone; - (NSString *)description { - NSString * descriptionString = [NSString stringWithFormat:@"<%@: constraints:%@; >", NSStringFromClass([self class]), _constraints]; + NSString * descriptionString = [NSString stringWithFormat:@"<%@: constraints:%@; cause:%@; >", NSStringFromClass([self class]), _constraints, _cause]; return descriptionString; } @@ -16466,6 +16493,82 @@ - (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader } } } + { + encodableStruct.cause = static_cast>(self.cause.unsignedCharValue); + } + + auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); + if (buffer.IsNull()) { + return CHIP_ERROR_NO_MEMORY; + } + + chip::System::PacketBufferTLVWriter writer; + // Commands never need chained buffers, since they cannot be chunked. + writer.Init(std::move(buffer), /* useChainedBuffers = */ false); + + ReturnErrorOnFailure(chip::app::DataModel::Encode(writer, chip::TLV::AnonymousTag(), encodableStruct)); + + ReturnErrorOnFailure(writer.Finalize(&buffer)); + + reader.Init(std::move(buffer)); + return reader.Next(chip::TLV::kTLVType_Structure, chip::TLV::AnonymousTag()); +} + +- (NSDictionary * _Nullable)_encodeAsDataValue:(NSError * __autoreleasing *)error +{ + chip::System::PacketBufferTLVReader reader; + CHIP_ERROR err = [self _encodeToTLVReader:reader]; + if (err != CHIP_NO_ERROR) { + if (error) { + *error = [MTRError errorForCHIPErrorCode:err]; + } + return nil; + } + + auto decodedObj = MTRDecodeDataValueDictionaryFromCHIPTLV(&reader); + if (decodedObj == nil) { + if (error) { + *error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE]; + } + } + return decodedObj; +} +@end + +@implementation MTRDeviceEnergyManagementClusterCancelRequestParams +- (instancetype)init +{ + if (self = [super init]) { + _timedInvokeTimeoutMs = nil; + _serverSideProcessingTimeout = nil; + } + return self; +} + +- (id)copyWithZone:(NSZone * _Nullable)zone; +{ + auto other = [[MTRDeviceEnergyManagementClusterCancelRequestParams alloc] init]; + + other.timedInvokeTimeoutMs = self.timedInvokeTimeoutMs; + other.serverSideProcessingTimeout = self.serverSideProcessingTimeout; + + return other; +} + +- (NSString *)description +{ + NSString * descriptionString = [NSString stringWithFormat:@"<%@: >", NSStringFromClass([self class])]; + return descriptionString; +} + +@end + +@implementation MTRDeviceEnergyManagementClusterCancelRequestParams (InternalMethods) + +- (CHIP_ERROR)_encodeToTLVReader:(chip::System::PacketBufferTLVReader &)reader +{ + chip::app::Clusters::DeviceEnergyManagement::Commands::CancelRequest::Type encodableStruct; + ListFreer listFreer; auto buffer = chip::System::PacketBufferHandle::New(chip::System::PacketBuffer::kMaxSizeWithoutReserve, 0); if (buffer.IsNull()) { diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h index 7b33d80c72c54b..8f2f5b835c45f2 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRCommandPayloads_Internal.h @@ -1096,6 +1096,12 @@ NS_ASSUME_NONNULL_BEGIN @end +@interface MTRDeviceEnergyManagementClusterCancelRequestParams (InternalMethods) + +- (NSDictionary * _Nullable)_encodeAsDataValue:(NSError * __autoreleasing *)error; + +@end + @interface MTREnergyEVSEClusterGetTargetsResponseParams (InternalMethods) - (CHIP_ERROR)_setFieldsFromDecodableStruct:(const chip::app::Clusters::EnergyEvse::Commands::GetTargetsResponse::DecodableType &)decodableStruct; diff --git a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm index 119031161f5195..bd2e8e5b3470b5 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTREventTLVValueDecoder.mm @@ -2863,6 +2863,12 @@ static id _Nullable DecodeEventPayloadForDeviceEnergyManagementCluster(EventId a __auto_type * value = [MTRDeviceEnergyManagementClusterResumedEvent new]; + do { + NSNumber * _Nonnull memberValue; + memberValue = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue.cause)]; + value.cause = memberValue; + } while (0); + return value; } default: { diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h index d57f138fa53256..0244d93dcea469 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.h @@ -1206,9 +1206,9 @@ MTR_PROVISIONALLY_AVAILABLE @property (nonatomic, copy) NSNumber * _Nonnull defaultDuration MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nonnull elapsedSlotTime MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nonnull remainingSlotTime MTR_PROVISIONALLY_AVAILABLE; -@property (nonatomic, copy) NSNumber * _Nonnull slotIsPauseable MTR_PROVISIONALLY_AVAILABLE; -@property (nonatomic, copy) NSNumber * _Nonnull minPauseDuration MTR_PROVISIONALLY_AVAILABLE; -@property (nonatomic, copy) NSNumber * _Nonnull maxPauseDuration MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable slotIsPauseable MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable minPauseDuration MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nullable maxPauseDuration MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nullable manufacturerESAState MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nullable nominalPower MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nullable minPower MTR_PROVISIONALLY_AVAILABLE; @@ -1231,6 +1231,7 @@ MTR_PROVISIONALLY_AVAILABLE @property (nonatomic, copy) NSNumber * _Nullable latestEndTime MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSNumber * _Nonnull isPauseable MTR_PROVISIONALLY_AVAILABLE; @property (nonatomic, copy) NSArray * _Nonnull slots MTR_PROVISIONALLY_AVAILABLE; +@property (nonatomic, copy) NSNumber * _Nonnull forecastUpdateReason MTR_PROVISIONALLY_AVAILABLE; @end MTR_PROVISIONALLY_AVAILABLE @@ -1274,6 +1275,7 @@ MTR_PROVISIONALLY_AVAILABLE MTR_PROVISIONALLY_AVAILABLE @interface MTRDeviceEnergyManagementClusterResumedEvent : NSObject +@property (nonatomic, copy) NSNumber * _Nonnull cause MTR_PROVISIONALLY_AVAILABLE; @end MTR_PROVISIONALLY_AVAILABLE diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm index 810e778412f5c8..22ee409b968bf3 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRStructsObjc.mm @@ -4887,11 +4887,11 @@ - (instancetype)init _remainingSlotTime = @(0); - _slotIsPauseable = @(0); + _slotIsPauseable = nil; - _minPauseDuration = @(0); + _minPauseDuration = nil; - _maxPauseDuration = @(0); + _maxPauseDuration = nil; _manufacturerESAState = nil; @@ -4970,6 +4970,8 @@ - (instancetype)init _isPauseable = @(0); _slots = [NSArray array]; + + _forecastUpdateReason = @(0); } return self; } @@ -4986,13 +4988,14 @@ - (id)copyWithZone:(NSZone * _Nullable)zone other.latestEndTime = self.latestEndTime; other.isPauseable = self.isPauseable; other.slots = self.slots; + other.forecastUpdateReason = self.forecastUpdateReason; return other; } - (NSString *)description { - NSString * descriptionString = [NSString stringWithFormat:@"<%@: forecastId:%@; activeSlotNumber:%@; startTime:%@; endTime:%@; earliestStartTime:%@; latestEndTime:%@; isPauseable:%@; slots:%@; >", NSStringFromClass([self class]), _forecastId, _activeSlotNumber, _startTime, _endTime, _earliestStartTime, _latestEndTime, _isPauseable, _slots]; + NSString * descriptionString = [NSString stringWithFormat:@"<%@: forecastId:%@; activeSlotNumber:%@; startTime:%@; endTime:%@; earliestStartTime:%@; latestEndTime:%@; isPauseable:%@; slots:%@; forecastUpdateReason:%@; >", NSStringFromClass([self class]), _forecastId, _activeSlotNumber, _startTime, _endTime, _earliestStartTime, _latestEndTime, _isPauseable, _slots, _forecastUpdateReason]; return descriptionString; } @@ -5189,6 +5192,8 @@ @implementation MTRDeviceEnergyManagementClusterResumedEvent - (instancetype)init { if (self = [super init]) { + + _cause = @(0); } return self; } @@ -5197,12 +5202,14 @@ - (id)copyWithZone:(NSZone * _Nullable)zone { auto other = [[MTRDeviceEnergyManagementClusterResumedEvent alloc] init]; + other.cause = self.cause; + return other; } - (NSString *)description { - NSString * descriptionString = [NSString stringWithFormat:@"<%@: >", NSStringFromClass([self class])]; + NSString * descriptionString = [NSString stringWithFormat:@"<%@: cause:%@; >", NSStringFromClass([self class]), _cause]; return descriptionString; } diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h index fa83804118b175..97ea4eeb3ce0ac 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums-check.h @@ -1641,6 +1641,18 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DemandResponseLoadContr } } +static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement::AdjustmentCauseEnum val) +{ + using EnumType = DeviceEnergyManagement::AdjustmentCauseEnum; + switch (val) + { + case EnumType::kLocalOptimization: + case EnumType::kGridOptimization: + return val; + default: + return static_cast(2); + } +} static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement::CauseEnum val) { using EnumType = DeviceEnergyManagement::CauseEnum; @@ -1650,9 +1662,10 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement: case EnumType::kOffline: case EnumType::kFault: case EnumType::kUserOptOut: + case EnumType::kCancelled: return val; default: - return static_cast(4); + return static_cast(5); } } static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement::CostTypeEnum val) @@ -1677,12 +1690,11 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement: case EnumType::kOffline: case EnumType::kOnline: case EnumType::kFault: - case EnumType::kUserOptOut: case EnumType::kPowerAdjustActive: case EnumType::kPaused: return val; default: - return static_cast(6); + return static_cast(5); } } static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement::ESATypeEnum val) @@ -1710,6 +1722,33 @@ static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement: return static_cast(14); } } +static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement::ForecastUpdateReasonEnum val) +{ + using EnumType = DeviceEnergyManagement::ForecastUpdateReasonEnum; + switch (val) + { + case EnumType::kInternalOptimization: + case EnumType::kLocalOptimization: + case EnumType::kGridOptimization: + return val; + default: + return static_cast(3); + } +} +static auto __attribute__((unused)) EnsureKnownEnumValue(DeviceEnergyManagement::OptOutStateEnum val) +{ + using EnumType = DeviceEnergyManagement::OptOutStateEnum; + switch (val) + { + case EnumType::kNoOptOut: + case EnumType::kLocalOptOut: + case EnumType::kGridOptOut: + case EnumType::kOptOut: + return val; + default: + return static_cast(4); + } +} static auto __attribute__((unused)) EnsureKnownEnumValue(EnergyEvse::EnergyTransferStoppedReasonEnum val) { diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h index 49b66ec661f0eb..4dd5c7f4db2735 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-enums.h @@ -2380,6 +2380,18 @@ enum class Feature : uint32_t namespace DeviceEnergyManagement { +// Enum for AdjustmentCauseEnum +enum class AdjustmentCauseEnum : uint8_t +{ + kLocalOptimization = 0x00, + kGridOptimization = 0x01, + // All received enum values that are not listed above will be mapped + // to kUnknownEnumValue. This is a helper enum value that should only + // be used by code to process how it handles receiving and unknown + // enum value. This specific should never be transmitted. + kUnknownEnumValue = 2, +}; + // Enum for CauseEnum enum class CauseEnum : uint8_t { @@ -2387,11 +2399,12 @@ enum class CauseEnum : uint8_t kOffline = 0x01, kFault = 0x02, kUserOptOut = 0x03, + kCancelled = 0x04, // All received enum values that are not listed above will be mapped // to kUnknownEnumValue. This is a helper enum value that should only // be used by code to process how it handles receiving and unknown // enum value. This specific should never be transmitted. - kUnknownEnumValue = 4, + kUnknownEnumValue = 5, }; // Enum for CostTypeEnum @@ -2414,14 +2427,13 @@ enum class ESAStateEnum : uint8_t kOffline = 0x00, kOnline = 0x01, kFault = 0x02, - kUserOptOut = 0x03, - kPowerAdjustActive = 0x04, - kPaused = 0x05, + kPowerAdjustActive = 0x03, + kPaused = 0x04, // All received enum values that are not listed above will be mapped // to kUnknownEnumValue. This is a helper enum value that should only // be used by code to process how it handles receiving and unknown // enum value. This specific should never be transmitted. - kUnknownEnumValue = 6, + kUnknownEnumValue = 5, }; // Enum for ESATypeEnum @@ -2449,13 +2461,43 @@ enum class ESATypeEnum : uint8_t kUnknownEnumValue = 14, }; +// Enum for ForecastUpdateReasonEnum +enum class ForecastUpdateReasonEnum : uint8_t +{ + kInternalOptimization = 0x00, + kLocalOptimization = 0x01, + kGridOptimization = 0x02, + // All received enum values that are not listed above will be mapped + // to kUnknownEnumValue. This is a helper enum value that should only + // be used by code to process how it handles receiving and unknown + // enum value. This specific should never be transmitted. + kUnknownEnumValue = 3, +}; + +// Enum for OptOutStateEnum +enum class OptOutStateEnum : uint8_t +{ + kNoOptOut = 0x00, + kLocalOptOut = 0x01, + kGridOptOut = 0x02, + kOptOut = 0x03, + // All received enum values that are not listed above will be mapped + // to kUnknownEnumValue. This is a helper enum value that should only + // be used by code to process how it handles receiving and unknown + // enum value. This specific should never be transmitted. + kUnknownEnumValue = 4, +}; + // Bitmap for Feature enum class Feature : uint32_t { - kPowerAdjustment = 0x1, - kPowerForecastReporting = 0x2, - kStateForecastReporting = 0x4, - kForecastAdjustment = 0x8, + kPowerAdjustment = 0x1, + kPowerForecastReporting = 0x2, + kStateForecastReporting = 0x4, + kStartTimeAdjustment = 0x8, + kPausable = 0x10, + kForecastAdjustment = 0x20, + kConstraintBasedAdjustment = 0x40, }; } // namespace DeviceEnergyManagement diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp index a0d28f1a74cb05..7d617579e01e93 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp @@ -15262,6 +15262,7 @@ CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const encoder.Encode(to_underlying(Fields::kLatestEndTime), latestEndTime); encoder.Encode(to_underlying(Fields::kIsPauseable), isPauseable); encoder.Encode(to_underlying(Fields::kSlots), slots); + encoder.Encode(to_underlying(Fields::kForecastUpdateReason), forecastUpdateReason); return encoder.Finalize(); } @@ -15311,6 +15312,10 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) { err = DataModel::Decode(reader, slots); } + else if (__context_tag == to_underlying(Fields::kForecastUpdateReason)) + { + err = DataModel::Decode(reader, forecastUpdateReason); + } else { } @@ -15482,6 +15487,7 @@ CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; encoder.Encode(to_underlying(Fields::kPower), power); encoder.Encode(to_underlying(Fields::kDuration), duration); + encoder.Encode(to_underlying(Fields::kCause), cause); return encoder.Finalize(); } @@ -15507,6 +15513,10 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) { err = DataModel::Decode(reader, duration); } + else if (__context_tag == to_underlying(Fields::kCause)) + { + err = DataModel::Decode(reader, cause); + } else { } @@ -15540,6 +15550,7 @@ CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const { DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; encoder.Encode(to_underlying(Fields::kRequestedStartTime), requestedStartTime); + encoder.Encode(to_underlying(Fields::kCause), cause); return encoder.Finalize(); } @@ -15561,6 +15572,10 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) { err = DataModel::Decode(reader, requestedStartTime); } + else if (__context_tag == to_underlying(Fields::kCause)) + { + err = DataModel::Decode(reader, cause); + } else { } @@ -15574,6 +15589,7 @@ CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const { DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; encoder.Encode(to_underlying(Fields::kDuration), duration); + encoder.Encode(to_underlying(Fields::kCause), cause); return encoder.Finalize(); } @@ -15595,6 +15611,10 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) { err = DataModel::Decode(reader, duration); } + else if (__context_tag == to_underlying(Fields::kCause)) + { + err = DataModel::Decode(reader, cause); + } else { } @@ -15629,6 +15649,7 @@ CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; encoder.Encode(to_underlying(Fields::kForecastId), forecastId); encoder.Encode(to_underlying(Fields::kSlotAdjustments), slotAdjustments); + encoder.Encode(to_underlying(Fields::kCause), cause); return encoder.Finalize(); } @@ -15654,6 +15675,10 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) { err = DataModel::Decode(reader, slotAdjustments); } + else if (__context_tag == to_underlying(Fields::kCause)) + { + err = DataModel::Decode(reader, cause); + } else { } @@ -15667,6 +15692,7 @@ CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const { DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; encoder.Encode(to_underlying(Fields::kConstraints), constraints); + encoder.Encode(to_underlying(Fields::kCause), cause); return encoder.Finalize(); } @@ -15688,6 +15714,10 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) { err = DataModel::Decode(reader, constraints); } + else if (__context_tag == to_underlying(Fields::kCause)) + { + err = DataModel::Decode(reader, cause); + } else { } @@ -15696,6 +15726,26 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) } } } // namespace RequestConstraintBasedForecast. +namespace CancelRequest { +CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const +{ + DataModel::WrappedStructEncoder encoder{ aWriter, aTag }; + return encoder.Finalize(); +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + detail::StructDecodeIterator __iterator(reader); + while (true) + { + auto __element = __iterator.Next(); + if (std::holds_alternative(__element)) + { + return std::get(__element); + } + } +} +} // namespace CancelRequest. } // namespace Commands namespace Attributes { @@ -15717,6 +15767,8 @@ CHIP_ERROR TypeInfo::DecodableType::Decode(TLV::TLVReader & reader, const Concre return DataModel::Decode(reader, powerAdjustmentCapability); case Attributes::Forecast::TypeInfo::GetAttributeId(): return DataModel::Decode(reader, forecast); + case Attributes::OptOutState::TypeInfo::GetAttributeId(): + return DataModel::Decode(reader, optOutState); case Attributes::GeneratedCommandList::TypeInfo::GetAttributeId(): return DataModel::Decode(reader, generatedCommandList); case Attributes::AcceptedCommandList::TypeInfo::GetAttributeId(): @@ -15828,6 +15880,7 @@ CHIP_ERROR Type::Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const { TLV::TLVType outer; ReturnErrorOnFailure(aWriter.StartContainer(aTag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(aWriter, TLV::ContextTag(Fields::kCause), cause)); return aWriter.EndContainer(outer); } @@ -15841,6 +15894,19 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) { return std::get(__element); } + + CHIP_ERROR err = CHIP_NO_ERROR; + const uint8_t __context_tag = std::get(__element); + + if (__context_tag == to_underlying(Fields::kCause)) + { + err = DataModel::Decode(reader, cause); + } + else + { + } + + ReturnErrorOnFailure(err); } } } // namespace Resumed. diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h index f85e0335903656..aa3effd58f758e 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h @@ -21346,9 +21346,9 @@ struct Type uint32_t defaultDuration = static_cast(0); uint32_t elapsedSlotTime = static_cast(0); uint32_t remainingSlotTime = static_cast(0); - bool slotIsPauseable = static_cast(0); - uint32_t minPauseDuration = static_cast(0); - uint32_t maxPauseDuration = static_cast(0); + Optional slotIsPauseable; + Optional minPauseDuration; + Optional maxPauseDuration; Optional manufacturerESAState; Optional nominalPower; Optional minPower; @@ -21373,9 +21373,9 @@ struct DecodableType uint32_t defaultDuration = static_cast(0); uint32_t elapsedSlotTime = static_cast(0); uint32_t remainingSlotTime = static_cast(0); - bool slotIsPauseable = static_cast(0); - uint32_t minPauseDuration = static_cast(0); - uint32_t maxPauseDuration = static_cast(0); + Optional slotIsPauseable; + Optional minPauseDuration; + Optional maxPauseDuration; Optional manufacturerESAState; Optional nominalPower; Optional minPower; @@ -21396,14 +21396,15 @@ struct DecodableType namespace ForecastStruct { enum class Fields : uint8_t { - kForecastId = 0, - kActiveSlotNumber = 1, - kStartTime = 2, - kEndTime = 3, - kEarliestStartTime = 4, - kLatestEndTime = 5, - kIsPauseable = 6, - kSlots = 7, + kForecastId = 0, + kActiveSlotNumber = 1, + kStartTime = 2, + kEndTime = 3, + kEarliestStartTime = 4, + kLatestEndTime = 5, + kIsPauseable = 6, + kSlots = 7, + kForecastUpdateReason = 8, }; struct Type @@ -21417,6 +21418,7 @@ struct Type Optional latestEndTime; bool isPauseable = static_cast(0); DataModel::List slots; + ForecastUpdateReasonEnum forecastUpdateReason = static_cast(0); static constexpr bool kIsFabricScoped = false; @@ -21434,6 +21436,7 @@ struct DecodableType Optional latestEndTime; bool isPauseable = static_cast(0); DataModel::DecodableList slots; + ForecastUpdateReasonEnum forecastUpdateReason = static_cast(0); CHIP_ERROR Decode(TLV::TLVReader & reader); @@ -21562,6 +21565,11 @@ struct Type; struct DecodableType; } // namespace RequestConstraintBasedForecast +namespace CancelRequest { +struct Type; +struct DecodableType; +} // namespace CancelRequest + } // namespace Commands namespace Commands { @@ -21570,6 +21578,7 @@ enum class Fields : uint8_t { kPower = 0, kDuration = 1, + kCause = 2, }; struct Type @@ -21579,8 +21588,9 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::PowerAdjustRequest::Id; } static constexpr ClusterId GetClusterId() { return Clusters::DeviceEnergyManagement::Id; } - int64_t power = static_cast(0); - uint32_t duration = static_cast(0); + int64_t power = static_cast(0); + uint32_t duration = static_cast(0); + AdjustmentCauseEnum cause = static_cast(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -21595,8 +21605,9 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::PowerAdjustRequest::Id; } static constexpr ClusterId GetClusterId() { return Clusters::DeviceEnergyManagement::Id; } - int64_t power = static_cast(0); - uint32_t duration = static_cast(0); + int64_t power = static_cast(0); + uint32_t duration = static_cast(0); + AdjustmentCauseEnum cause = static_cast(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace PowerAdjustRequest @@ -21632,6 +21643,7 @@ namespace StartTimeAdjustRequest { enum class Fields : uint8_t { kRequestedStartTime = 0, + kCause = 1, }; struct Type @@ -21642,6 +21654,7 @@ struct Type static constexpr ClusterId GetClusterId() { return Clusters::DeviceEnergyManagement::Id; } uint32_t requestedStartTime = static_cast(0); + AdjustmentCauseEnum cause = static_cast(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -21657,6 +21670,7 @@ struct DecodableType static constexpr ClusterId GetClusterId() { return Clusters::DeviceEnergyManagement::Id; } uint32_t requestedStartTime = static_cast(0); + AdjustmentCauseEnum cause = static_cast(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace StartTimeAdjustRequest @@ -21664,6 +21678,7 @@ namespace PauseRequest { enum class Fields : uint8_t { kDuration = 0, + kCause = 1, }; struct Type @@ -21673,7 +21688,8 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::PauseRequest::Id; } static constexpr ClusterId GetClusterId() { return Clusters::DeviceEnergyManagement::Id; } - uint32_t duration = static_cast(0); + uint32_t duration = static_cast(0); + AdjustmentCauseEnum cause = static_cast(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -21688,7 +21704,8 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::PauseRequest::Id; } static constexpr ClusterId GetClusterId() { return Clusters::DeviceEnergyManagement::Id; } - uint32_t duration = static_cast(0); + uint32_t duration = static_cast(0); + AdjustmentCauseEnum cause = static_cast(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace PauseRequest @@ -21725,6 +21742,7 @@ enum class Fields : uint8_t { kForecastId = 0, kSlotAdjustments = 1, + kCause = 2, }; struct Type @@ -21736,6 +21754,7 @@ struct Type uint32_t forecastId = static_cast(0); DataModel::List slotAdjustments; + AdjustmentCauseEnum cause = static_cast(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -21752,6 +21771,7 @@ struct DecodableType uint32_t forecastId = static_cast(0); DataModel::DecodableList slotAdjustments; + AdjustmentCauseEnum cause = static_cast(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace ModifyForecastRequest @@ -21759,6 +21779,7 @@ namespace RequestConstraintBasedForecast { enum class Fields : uint8_t { kConstraints = 0, + kCause = 1, }; struct Type @@ -21769,6 +21790,7 @@ struct Type static constexpr ClusterId GetClusterId() { return Clusters::DeviceEnergyManagement::Id; } DataModel::List constraints; + AdjustmentCauseEnum cause = static_cast(0); CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; @@ -21784,9 +21806,38 @@ struct DecodableType static constexpr ClusterId GetClusterId() { return Clusters::DeviceEnergyManagement::Id; } DataModel::DecodableList constraints; + AdjustmentCauseEnum cause = static_cast(0); CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace RequestConstraintBasedForecast +namespace CancelRequest { +enum class Fields : uint8_t +{ +}; + +struct Type +{ +public: + // Use GetCommandId instead of commandId directly to avoid naming conflict with CommandIdentification in ExecutionOfACommand + static constexpr CommandId GetCommandId() { return Commands::CancelRequest::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::DeviceEnergyManagement::Id; } + + CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; + + using ResponseType = DataModel::NullObjectType; + + static constexpr bool MustUseTimedInvoke() { return false; } +}; + +struct DecodableType +{ +public: + static constexpr CommandId GetCommandId() { return Commands::CancelRequest::Id; } + static constexpr ClusterId GetClusterId() { return Clusters::DeviceEnergyManagement::Id; } + + CHIP_ERROR Decode(TLV::TLVReader & reader); +}; +}; // namespace CancelRequest } // namespace Commands namespace Attributes { @@ -21880,6 +21931,18 @@ struct TypeInfo static constexpr bool MustUseTimedWrite() { return false; } }; } // namespace Forecast +namespace OptOutState { +struct TypeInfo +{ + using Type = chip::app::Clusters::DeviceEnergyManagement::OptOutStateEnum; + using DecodableType = chip::app::Clusters::DeviceEnergyManagement::OptOutStateEnum; + using DecodableArgType = chip::app::Clusters::DeviceEnergyManagement::OptOutStateEnum; + + static constexpr ClusterId GetClusterId() { return Clusters::DeviceEnergyManagement::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::OptOutState::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace OptOutState namespace GeneratedCommandList { struct TypeInfo : public Clusters::Globals::Attributes::GeneratedCommandList::TypeInfo { @@ -21934,6 +21997,8 @@ struct TypeInfo Attributes::AbsMaxPower::TypeInfo::DecodableType absMaxPower = static_cast(0); Attributes::PowerAdjustmentCapability::TypeInfo::DecodableType powerAdjustmentCapability; Attributes::Forecast::TypeInfo::DecodableType forecast; + Attributes::OptOutState::TypeInfo::DecodableType optOutState = + static_cast(0); Attributes::GeneratedCommandList::TypeInfo::DecodableType generatedCommandList; Attributes::AcceptedCommandList::TypeInfo::DecodableType acceptedCommandList; Attributes::EventList::TypeInfo::DecodableType eventList; @@ -22044,6 +22109,7 @@ static constexpr PriorityLevel kPriorityLevel = PriorityLevel::Info; enum class Fields : uint8_t { + kCause = 0, }; struct Type @@ -22054,6 +22120,8 @@ struct Type static constexpr ClusterId GetClusterId() { return Clusters::DeviceEnergyManagement::Id; } static constexpr bool kIsFabricScoped = false; + CauseEnum cause = static_cast(0); + CHIP_ERROR Encode(TLV::TLVWriter & aWriter, TLV::Tag aTag) const; }; @@ -22064,6 +22132,8 @@ struct DecodableType static constexpr EventId GetEventId() { return Events::Resumed::Id; } static constexpr ClusterId GetClusterId() { return Clusters::DeviceEnergyManagement::Id; } + CauseEnum cause = static_cast(0); + CHIP_ERROR Decode(TLV::TLVReader & reader); }; } // namespace Resumed diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h b/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h index f2ce8f91f96885..1e237a2601cfd8 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h @@ -3812,6 +3812,10 @@ namespace Forecast { static constexpr AttributeId Id = 0x00000006; } // namespace Forecast +namespace OptOutState { +static constexpr AttributeId Id = 0x00000007; +} // namespace OptOutState + namespace GeneratedCommandList { static constexpr AttributeId Id = Globals::Attributes::GeneratedCommandList::Id; } // namespace GeneratedCommandList diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h b/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h index 76ed4e215d1092..f5607a6ba0e910 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Commands.h @@ -1002,6 +1002,10 @@ namespace RequestConstraintBasedForecast { static constexpr CommandId Id = 0x00000006; } // namespace RequestConstraintBasedForecast +namespace CancelRequest { +static constexpr CommandId Id = 0x00000007; +} // namespace CancelRequest + } // namespace Commands } // namespace DeviceEnergyManagement diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index 12c9198618fac5..2b03b673a1292a 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -6896,6 +6896,7 @@ class DemandResponseLoadControlClearLoadControlEventsRequest : public ClusterCom | * ResumeRequest | 0x04 | | * ModifyForecastRequest | 0x05 | | * RequestConstraintBasedForecast | 0x06 | +| * CancelRequest | 0x07 | |------------------------------------------------------------------------------| | Attributes: | | | * ESAType | 0x0000 | @@ -6905,6 +6906,7 @@ class DemandResponseLoadControlClearLoadControlEventsRequest : public ClusterCom | * AbsMaxPower | 0x0004 | | * PowerAdjustmentCapability | 0x0005 | | * Forecast | 0x0006 | +| * OptOutState | 0x0007 | | * GeneratedCommandList | 0xFFF8 | | * AcceptedCommandList | 0xFFF9 | | * EventList | 0xFFFA | @@ -6930,6 +6932,7 @@ class DeviceEnergyManagementPowerAdjustRequest : public ClusterCommand { AddArgument("Power", INT64_MIN, INT64_MAX, &mRequest.power); AddArgument("Duration", 0, UINT32_MAX, &mRequest.duration); + AddArgument("Cause", 0, UINT8_MAX, &mRequest.cause); ClusterCommand::AddArguments(); } @@ -7005,6 +7008,7 @@ class DeviceEnergyManagementStartTimeAdjustRequest : public ClusterCommand ClusterCommand("start-time-adjust-request", credsIssuerConfig) { AddArgument("RequestedStartTime", 0, UINT32_MAX, &mRequest.requestedStartTime); + AddArgument("Cause", 0, UINT8_MAX, &mRequest.cause); ClusterCommand::AddArguments(); } @@ -7043,6 +7047,7 @@ class DeviceEnergyManagementPauseRequest : public ClusterCommand ClusterCommand("pause-request", credsIssuerConfig) { AddArgument("Duration", 0, UINT32_MAX, &mRequest.duration); + AddArgument("Cause", 0, UINT8_MAX, &mRequest.cause); ClusterCommand::AddArguments(); } @@ -7119,6 +7124,7 @@ class DeviceEnergyManagementModifyForecastRequest : public ClusterCommand { AddArgument("ForecastId", 0, UINT32_MAX, &mRequest.forecastId); AddArgument("SlotAdjustments", &mComplex_SlotAdjustments); + AddArgument("Cause", 0, UINT8_MAX, &mRequest.cause); ClusterCommand::AddArguments(); } @@ -7160,6 +7166,7 @@ class DeviceEnergyManagementRequestConstraintBasedForecast : public ClusterComma ClusterCommand("request-constraint-based-forecast", credsIssuerConfig), mComplex_Constraints(&mRequest.constraints) { AddArgument("Constraints", &mComplex_Constraints); + AddArgument("Cause", 0, UINT8_MAX, &mRequest.cause); ClusterCommand::AddArguments(); } @@ -7193,6 +7200,43 @@ class DeviceEnergyManagementRequestConstraintBasedForecast : public ClusterComma mComplex_Constraints; }; +/* + * Command CancelRequest + */ +class DeviceEnergyManagementCancelRequest : public ClusterCommand +{ +public: + DeviceEnergyManagementCancelRequest(CredentialIssuerCommands * credsIssuerConfig) : + ClusterCommand("cancel-request", credsIssuerConfig) + { + ClusterCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(chip::DeviceProxy * device, std::vector endpointIds) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::DeviceEnergyManagement::Id; + constexpr chip::CommandId commandId = chip::app::Clusters::DeviceEnergyManagement::Commands::CancelRequest::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") command (0x%08" PRIX32 ") on endpoint %u", clusterId, + commandId, endpointIds.at(0)); + return ClusterCommand::SendCommand(device, endpointIds.at(0), clusterId, commandId, mRequest); + } + + CHIP_ERROR SendGroupCommand(chip::GroupId groupId, chip::FabricIndex fabricIndex) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::DeviceEnergyManagement::Id; + constexpr chip::CommandId commandId = chip::app::Clusters::DeviceEnergyManagement::Commands::CancelRequest::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") command (0x%08" PRIX32 ") on Group %u", clusterId, commandId, + groupId); + + return ClusterCommand::SendGroupCommand(groupId, fabricIndex, clusterId, commandId, mRequest); + } + +private: + chip::app::Clusters::DeviceEnergyManagement::Commands::CancelRequest::Type mRequest; +}; + /*----------------------------------------------------------------------------*\ | Cluster EnergyEvse | 0x0099 | |------------------------------------------------------------------------------| @@ -20135,6 +20179,7 @@ void registerClusterDeviceEnergyManagement(Commands & commands, CredentialIssuer make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // make_unique(credsIssuerConfig), // + make_unique(credsIssuerConfig), // // // Attributes // @@ -20147,6 +20192,7 @@ void registerClusterDeviceEnergyManagement(Commands & commands, CredentialIssuer make_unique(Id, "power-adjustment-capability", Attributes::PowerAdjustmentCapability::Id, credsIssuerConfig), // make_unique(Id, "forecast", Attributes::Forecast::Id, credsIssuerConfig), // + make_unique(Id, "opt-out-state", Attributes::OptOutState::Id, credsIssuerConfig), // make_unique(Id, "generated-command-list", Attributes::GeneratedCommandList::Id, credsIssuerConfig), // make_unique(Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, credsIssuerConfig), // make_unique(Id, "event-list", Attributes::EventList::Id, credsIssuerConfig), // @@ -20171,6 +20217,8 @@ void registerClusterDeviceEnergyManagement(Commands & commands, CredentialIssuer make_unique>>( Id, "forecast", Attributes::Forecast::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // + make_unique>( + Id, "opt-out-state", 0, UINT8_MAX, Attributes::OptOutState::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // make_unique>>( Id, "generated-command-list", Attributes::GeneratedCommandList::Id, WriteCommandType::kForceWrite, credsIssuerConfig), // @@ -20193,6 +20241,7 @@ void registerClusterDeviceEnergyManagement(Commands & commands, CredentialIssuer make_unique(Id, "power-adjustment-capability", Attributes::PowerAdjustmentCapability::Id, credsIssuerConfig), // make_unique(Id, "forecast", Attributes::Forecast::Id, credsIssuerConfig), // + make_unique(Id, "opt-out-state", Attributes::OptOutState::Id, credsIssuerConfig), // make_unique(Id, "generated-command-list", Attributes::GeneratedCommandList::Id, credsIssuerConfig), // make_unique(Id, "accepted-command-list", Attributes::AcceptedCommandList::Id, credsIssuerConfig), // make_unique(Id, "event-list", Attributes::EventList::Id, credsIssuerConfig), // diff --git a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp index 2d016ac47c8996..302cafb0a0b37b 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp @@ -2853,12 +2853,6 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, value.isMember("elapsedSlotTime"))); ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SlotStruct.remainingSlotTime", "remainingSlotTime", value.isMember("remainingSlotTime"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SlotStruct.slotIsPauseable", "slotIsPauseable", - value.isMember("slotIsPauseable"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SlotStruct.minPauseDuration", "minPauseDuration", - value.isMember("minPauseDuration"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SlotStruct.maxPauseDuration", "maxPauseDuration", - value.isMember("maxPauseDuration"))); char labelWithMember[kMaxLabelLength]; snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "minDuration"); @@ -2881,16 +2875,25 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.remainingSlotTime, value["remainingSlotTime"])); valueCopy.removeMember("remainingSlotTime"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "slotIsPauseable"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.slotIsPauseable, value["slotIsPauseable"])); + if (value.isMember("slotIsPauseable")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "slotIsPauseable"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.slotIsPauseable, value["slotIsPauseable"])); + } valueCopy.removeMember("slotIsPauseable"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "minPauseDuration"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.minPauseDuration, value["minPauseDuration"])); + if (value.isMember("minPauseDuration")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "minPauseDuration"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.minPauseDuration, value["minPauseDuration"])); + } valueCopy.removeMember("minPauseDuration"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "maxPauseDuration"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.maxPauseDuration, value["maxPauseDuration"])); + if (value.isMember("maxPauseDuration")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "maxPauseDuration"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.maxPauseDuration, value["maxPauseDuration"])); + } valueCopy.removeMember("maxPauseDuration"); if (value.isMember("manufacturerESAState")) @@ -3012,6 +3015,8 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, ReturnErrorOnFailure( ComplexArgumentParser::EnsureMemberExist("ForecastStruct.isPauseable", "isPauseable", value.isMember("isPauseable"))); ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ForecastStruct.slots", "slots", value.isMember("slots"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ForecastStruct.forecastUpdateReason", "forecastUpdateReason", + value.isMember("forecastUpdateReason"))); char labelWithMember[kMaxLabelLength]; snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "forecastId"); @@ -3052,6 +3057,11 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.slots, value["slots"])); valueCopy.removeMember("slots"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "forecastUpdateReason"); + ReturnErrorOnFailure( + ComplexArgumentParser::Setup(labelWithMember, request.forecastUpdateReason, value["forecastUpdateReason"])); + valueCopy.removeMember("forecastUpdateReason"); + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } @@ -3065,6 +3075,7 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::DeviceEnergyManagement ComplexArgumentParser::Finalize(request.latestEndTime); ComplexArgumentParser::Finalize(request.isPauseable); ComplexArgumentParser::Finalize(request.slots); + ComplexArgumentParser::Finalize(request.forecastUpdateReason); } CHIP_ERROR ComplexArgumentParser::Setup(const char * label, diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp index 4026dc9e4e0dd3..9967c2f53d4203 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp @@ -2727,6 +2727,14 @@ DataModelLogger::LogValue(const char * label, size_t indent, return err; } } + { + CHIP_ERROR err = LogValue("ForecastUpdateReason", indent + 1, value.forecastUpdateReason); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ForecastUpdateReason'"); + return err; + } + } DataModelLogger::LogString(indent, "}"); return CHIP_NO_ERROR; @@ -6071,6 +6079,14 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const DeviceEnergyManagement::Events::Resumed::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = DataModelLogger::LogValue("Cause", indent + 1, value.cause); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Event truncated due to invalid value for 'Cause'"); + return err; + } + } DataModelLogger::LogString(indent, "}"); return CHIP_NO_ERROR; @@ -12281,6 +12297,11 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); return DataModelLogger::LogValue("Forecast", 1, value); } + case DeviceEnergyManagement::Attributes::OptOutState::Id: { + chip::app::Clusters::DeviceEnergyManagement::OptOutStateEnum value; + ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); + return DataModelLogger::LogValue("OptOutState", 1, value); + } case DeviceEnergyManagement::Attributes::GeneratedCommandList::Id: { chip::app::DataModel::DecodableList value; ReturnErrorOnFailure(chip::app::DataModel::Decode(*data, value)); diff --git a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h index 85d892b9960f75..8029dc30320e82 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/cluster/Commands.h @@ -79653,6 +79653,7 @@ class SubscribeAttributeDemandResponseLoadControlClusterRevision : public Subscr | * ResumeRequest | 0x04 | | * ModifyForecastRequest | 0x05 | | * RequestConstraintBasedForecast | 0x06 | +| * CancelRequest | 0x07 | |------------------------------------------------------------------------------| | Attributes: | | | * ESAType | 0x0000 | @@ -79662,6 +79663,7 @@ class SubscribeAttributeDemandResponseLoadControlClusterRevision : public Subscr | * AbsMaxPower | 0x0004 | | * PowerAdjustmentCapability | 0x0005 | | * Forecast | 0x0006 | +| * OptOutState | 0x0007 | | * GeneratedCommandList | 0xFFF8 | | * AcceptedCommandList | 0xFFF9 | | * EventList | 0xFFFA | @@ -79690,6 +79692,9 @@ class DeviceEnergyManagementPowerAdjustRequest : public ClusterCommand { #endif // MTR_ENABLE_PROVISIONAL #if MTR_ENABLE_PROVISIONAL AddArgument("Duration", 0, UINT32_MAX, &mRequest.duration); +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + AddArgument("Cause", 0, UINT8_MAX, &mRequest.cause); #endif // MTR_ENABLE_PROVISIONAL ClusterCommand::AddArguments(); } @@ -79710,6 +79715,9 @@ class DeviceEnergyManagementPowerAdjustRequest : public ClusterCommand { #endif // MTR_ENABLE_PROVISIONAL #if MTR_ENABLE_PROVISIONAL params.duration = [NSNumber numberWithUnsignedInt:mRequest.duration]; +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + params.cause = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.cause)]; #endif // MTR_ENABLE_PROVISIONAL uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; @@ -79792,6 +79800,9 @@ class DeviceEnergyManagementStartTimeAdjustRequest : public ClusterCommand { { #if MTR_ENABLE_PROVISIONAL AddArgument("RequestedStartTime", 0, UINT32_MAX, &mRequest.requestedStartTime); +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + AddArgument("Cause", 0, UINT8_MAX, &mRequest.cause); #endif // MTR_ENABLE_PROVISIONAL ClusterCommand::AddArguments(); } @@ -79809,6 +79820,9 @@ class DeviceEnergyManagementStartTimeAdjustRequest : public ClusterCommand { params.timedInvokeTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; #if MTR_ENABLE_PROVISIONAL params.requestedStartTime = [NSNumber numberWithUnsignedInt:mRequest.requestedStartTime]; +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + params.cause = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.cause)]; #endif // MTR_ENABLE_PROVISIONAL uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; @@ -79845,6 +79859,9 @@ class DeviceEnergyManagementPauseRequest : public ClusterCommand { { #if MTR_ENABLE_PROVISIONAL AddArgument("Duration", 0, UINT32_MAX, &mRequest.duration); +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + AddArgument("Cause", 0, UINT8_MAX, &mRequest.cause); #endif // MTR_ENABLE_PROVISIONAL ClusterCommand::AddArguments(); } @@ -79862,6 +79879,9 @@ class DeviceEnergyManagementPauseRequest : public ClusterCommand { params.timedInvokeTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; #if MTR_ENABLE_PROVISIONAL params.duration = [NSNumber numberWithUnsignedInt:mRequest.duration]; +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + params.cause = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.cause)]; #endif // MTR_ENABLE_PROVISIONAL uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; @@ -79948,6 +79968,9 @@ class DeviceEnergyManagementModifyForecastRequest : public ClusterCommand { #endif // MTR_ENABLE_PROVISIONAL #if MTR_ENABLE_PROVISIONAL AddArgument("SlotAdjustments", &mComplex_SlotAdjustments); +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + AddArgument("Cause", 0, UINT8_MAX, &mRequest.cause); #endif // MTR_ENABLE_PROVISIONAL ClusterCommand::AddArguments(); } @@ -79979,6 +80002,9 @@ class DeviceEnergyManagementModifyForecastRequest : public ClusterCommand { } params.slotAdjustments = array_0; } +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + params.cause = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.cause)]; #endif // MTR_ENABLE_PROVISIONAL uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; @@ -80017,6 +80043,9 @@ class DeviceEnergyManagementRequestConstraintBasedForecast : public ClusterComma { #if MTR_ENABLE_PROVISIONAL AddArgument("Constraints", &mComplex_Constraints); +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + AddArgument("Cause", 0, UINT8_MAX, &mRequest.cause); #endif // MTR_ENABLE_PROVISIONAL ClusterCommand::AddArguments(); } @@ -80059,6 +80088,9 @@ class DeviceEnergyManagementRequestConstraintBasedForecast : public ClusterComma } params.constraints = array_0; } +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + params.cause = [NSNumber numberWithUnsignedChar:chip::to_underlying(mRequest.cause)]; #endif // MTR_ENABLE_PROVISIONAL uint16_t repeatCount = mRepeatCount.ValueOr(1); uint16_t __block responsesNeeded = repeatCount; @@ -80084,6 +80116,52 @@ class DeviceEnergyManagementRequestConstraintBasedForecast : public ClusterComma TypedComplexArgument> mComplex_Constraints; }; +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL +/* + * Command CancelRequest + */ +class DeviceEnergyManagementCancelRequest : public ClusterCommand { +public: + DeviceEnergyManagementCancelRequest() + : ClusterCommand("cancel-request") + { + ClusterCommand::AddArguments(); + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::DeviceEnergyManagement::Id; + constexpr chip::CommandId commandId = chip::app::Clusters::DeviceEnergyManagement::Commands::CancelRequest::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") command (0x%08" PRIX32 ") on endpoint %u", clusterId, commandId, endpointId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterDeviceEnergyManagement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRDeviceEnergyManagementClusterCancelRequestParams alloc] init]; + params.timedInvokeTimeoutMs = mTimedInteractionTimeoutMs.HasValue() ? [NSNumber numberWithUnsignedShort:mTimedInteractionTimeoutMs.Value()] : nil; + uint16_t repeatCount = mRepeatCount.ValueOr(1); + uint16_t __block responsesNeeded = repeatCount; + while (repeatCount--) { + [cluster cancelRequestWithParams:params completion: + ^(NSError * _Nullable error) { + responsesNeeded--; + if (error != nil) { + mError = error; + LogNSError("Error", error); + RemoteDataModelLogger::LogCommandErrorAsJSON(@(endpointId), @(clusterId), @(commandId), error); + } + if (responsesNeeded == 0) { + SetCommandExitStatus(mError); + } + }]; + } + return CHIP_NO_ERROR; + } + +private: +}; + #endif // MTR_ENABLE_PROVISIONAL #if MTR_ENABLE_PROVISIONAL @@ -80683,6 +80761,91 @@ class SubscribeAttributeDeviceEnergyManagementForecast : public SubscribeAttribu #endif // MTR_ENABLE_PROVISIONAL #if MTR_ENABLE_PROVISIONAL +/* + * Attribute OptOutState + */ +class ReadDeviceEnergyManagementOptOutState : public ReadAttribute { +public: + ReadDeviceEnergyManagementOptOutState() + : ReadAttribute("opt-out-state") + { + } + + ~ReadDeviceEnergyManagementOptOutState() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::DeviceEnergyManagement::Id; + constexpr chip::AttributeId attributeId = chip::app::Clusters::DeviceEnergyManagement::Attributes::OptOutState::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReadAttribute (0x%08" PRIX32 ") on endpoint %u", endpointId, clusterId, attributeId); + + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterDeviceEnergyManagement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + [cluster readAttributeOptOutStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"DeviceEnergyManagement.OptOutState response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + LogNSError("DeviceEnergyManagement OptOutState read Error", error); + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + return CHIP_NO_ERROR; + } +}; + +class SubscribeAttributeDeviceEnergyManagementOptOutState : public SubscribeAttribute { +public: + SubscribeAttributeDeviceEnergyManagementOptOutState() + : SubscribeAttribute("opt-out-state") + { + } + + ~SubscribeAttributeDeviceEnergyManagementOptOutState() + { + } + + CHIP_ERROR SendCommand(MTRBaseDevice * device, chip::EndpointId endpointId) override + { + constexpr chip::ClusterId clusterId = chip::app::Clusters::DeviceEnergyManagement::Id; + constexpr chip::CommandId attributeId = chip::app::Clusters::DeviceEnergyManagement::Attributes::OptOutState::Id; + + ChipLogProgress(chipTool, "Sending cluster (0x%08" PRIX32 ") ReportAttribute (0x%08" PRIX32 ") on endpoint %u", clusterId, attributeId, endpointId); + dispatch_queue_t callbackQueue = dispatch_queue_create("com.chip.command", DISPATCH_QUEUE_SERIAL); + __auto_type * cluster = [[MTRBaseClusterDeviceEnergyManagement alloc] initWithDevice:device endpointID:@(endpointId) queue:callbackQueue]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(mMinInterval) maxInterval:@(mMaxInterval)]; + if (mKeepSubscriptions.HasValue()) { + params.replaceExistingSubscriptions = !mKeepSubscriptions.Value(); + } + if (mFabricFiltered.HasValue()) { + params.filterByFabric = mFabricFiltered.Value(); + } + if (mAutoResubscribe.HasValue()) { + params.resubscribeAutomatically = mAutoResubscribe.Value(); + } + [cluster subscribeAttributeOptOutStateWithParams:params + subscriptionEstablished:^() { mSubscriptionEstablished = YES; } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable error) { + NSLog(@"DeviceEnergyManagement.OptOutState response %@", [value description]); + if (error == nil) { + RemoteDataModelLogger::LogAttributeAsJSON(@(endpointId), @(clusterId), @(attributeId), value); + } else { + RemoteDataModelLogger::LogAttributeErrorAsJSON(@(endpointId), @(clusterId), @(attributeId), error); + } + SetCommandExitStatus(error); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + /* * Attribute GeneratedCommandList */ @@ -181335,6 +181498,9 @@ void registerClusterDeviceEnergyManagement(Commands & commands) #endif // MTR_ENABLE_PROVISIONAL #if MTR_ENABLE_PROVISIONAL make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // #endif // MTR_ENABLE_PROVISIONAL make_unique(Id), // make_unique(Id), // @@ -181367,6 +181533,10 @@ void registerClusterDeviceEnergyManagement(Commands & commands) make_unique(), // make_unique(), // #endif // MTR_ENABLE_PROVISIONAL +#if MTR_ENABLE_PROVISIONAL + make_unique(), // + make_unique(), // +#endif // MTR_ENABLE_PROVISIONAL #if MTR_ENABLE_PROVISIONAL make_unique(), // make_unique(), //