Skip to content

Commit 9d4d762

Browse files
committed
Update device-energy-management-cluster.xml based on latest cluster spec and regenerate zap files
1 parent 923854b commit 9d4d762

File tree

45 files changed

+1724
-856
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1724
-856
lines changed

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

+25-14
Original file line numberDiff line numberDiff line change
@@ -4069,7 +4069,7 @@ cluster ElectricalEnergyMeasurement = 145 {
40694069

40704070
/** 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). */
40714071
provisional cluster DeviceEnergyManagement = 152 {
4072-
revision 3;
4072+
revision 4;
40734073

40744074
enum AdjustmentCauseEnum : enum8 {
40754075
kLocalOptimization = 0;
@@ -4130,6 +4130,12 @@ provisional cluster DeviceEnergyManagement = 152 {
41304130
kOptOut = 3;
41314131
}
41324132

4133+
enum PowerAdjustReasonEnum : enum8 {
4134+
kNoAdjustment = 0;
4135+
kLocalOptimizationAdjustment = 1;
4136+
kGridOptimizationAdjustment = 2;
4137+
}
4138+
41334139
bitmap Feature : bitmap32 {
41344140
kPowerAdjustment = 0x1;
41354141
kPowerForecastReporting = 0x2;
@@ -4147,13 +4153,25 @@ provisional cluster DeviceEnergyManagement = 152 {
41474153
optional int16u currency = 3;
41484154
}
41494155

4156+
struct PowerAdjustStruct {
4157+
power_mw minPower = 0;
4158+
power_mw maxPower = 1;
4159+
elapsed_s minDuration = 2;
4160+
elapsed_s maxDuration = 3;
4161+
}
4162+
4163+
struct PowerAdjustCapabilityStruct {
4164+
nullable PowerAdjustStruct powerAdjustCapability[] = 0;
4165+
PowerAdjustReasonEnum cause = 1;
4166+
}
4167+
41504168
struct SlotStruct {
41514169
elapsed_s minDuration = 0;
41524170
elapsed_s maxDuration = 1;
41534171
elapsed_s defaultDuration = 2;
41544172
elapsed_s elapsedSlotTime = 3;
41554173
elapsed_s remainingSlotTime = 4;
4156-
optional boolean slotIsPauseable = 5;
4174+
optional boolean slotIsPausable = 5;
41574175
optional elapsed_s minPauseDuration = 6;
41584176
optional elapsed_s maxPauseDuration = 7;
41594177
optional int16u manufacturerESAState = 8;
@@ -4169,13 +4187,13 @@ provisional cluster DeviceEnergyManagement = 152 {
41694187
}
41704188

41714189
struct ForecastStruct {
4172-
int16u forecastId = 0;
4190+
int32u forecastID = 0;
41734191
nullable int16u activeSlotNumber = 1;
41744192
epoch_s startTime = 2;
41754193
epoch_s endTime = 3;
41764194
optional nullable epoch_s earliestStartTime = 4;
41774195
optional epoch_s latestEndTime = 5;
4178-
boolean isPauseable = 6;
4196+
boolean isPausable = 6;
41794197
SlotStruct slots[] = 7;
41804198
ForecastUpdateReasonEnum forecastUpdateReason = 8;
41814199
}
@@ -4188,16 +4206,9 @@ provisional cluster DeviceEnergyManagement = 152 {
41884206
optional int8s loadControl = 4;
41894207
}
41904208

4191-
struct PowerAdjustStruct {
4192-
power_mw minPower = 0;
4193-
power_mw maxPower = 1;
4194-
elapsed_s minDuration = 2;
4195-
elapsed_s maxDuration = 3;
4196-
}
4197-
41984209
struct SlotAdjustmentStruct {
41994210
int8u slotIndex = 0;
4200-
power_mw nominalPower = 1;
4211+
optional power_mw nominalPower = 1;
42014212
elapsed_s duration = 2;
42024213
}
42034214

@@ -4222,7 +4233,7 @@ provisional cluster DeviceEnergyManagement = 152 {
42224233
readonly attribute ESAStateEnum ESAState = 2;
42234234
readonly attribute power_mw absMinPower = 3;
42244235
readonly attribute power_mw absMaxPower = 4;
4225-
readonly attribute optional nullable PowerAdjustStruct powerAdjustmentCapability[] = 5;
4236+
readonly attribute optional nullable PowerAdjustCapabilityStruct powerAdjustmentCapability = 5;
42264237
readonly attribute optional nullable ForecastStruct forecast = 6;
42274238
readonly attribute optional OptOutStateEnum optOutState = 7;
42284239
readonly attribute command_id generatedCommandList[] = 65528;
@@ -4249,7 +4260,7 @@ provisional cluster DeviceEnergyManagement = 152 {
42494260
}
42504261

42514262
request struct ModifyForecastRequestRequest {
4252-
int32u forecastId = 0;
4263+
int32u forecastID = 0;
42534264
SlotAdjustmentStruct slotAdjustments[] = 1;
42544265
AdjustmentCauseEnum cause = 2;
42554266
}

examples/energy-management-app/energy-management-common/energy-management-app.matter

+25-14
Original file line numberDiff line numberDiff line change
@@ -1430,7 +1430,7 @@ cluster ElectricalEnergyMeasurement = 145 {
14301430

14311431
/** 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). */
14321432
provisional cluster DeviceEnergyManagement = 152 {
1433-
revision 3;
1433+
revision 4;
14341434

14351435
enum AdjustmentCauseEnum : enum8 {
14361436
kLocalOptimization = 0;
@@ -1491,6 +1491,12 @@ provisional cluster DeviceEnergyManagement = 152 {
14911491
kOptOut = 3;
14921492
}
14931493

1494+
enum PowerAdjustReasonEnum : enum8 {
1495+
kNoAdjustment = 0;
1496+
kLocalOptimizationAdjustment = 1;
1497+
kGridOptimizationAdjustment = 2;
1498+
}
1499+
14941500
bitmap Feature : bitmap32 {
14951501
kPowerAdjustment = 0x1;
14961502
kPowerForecastReporting = 0x2;
@@ -1508,13 +1514,25 @@ provisional cluster DeviceEnergyManagement = 152 {
15081514
optional int16u currency = 3;
15091515
}
15101516

1517+
struct PowerAdjustStruct {
1518+
power_mw minPower = 0;
1519+
power_mw maxPower = 1;
1520+
elapsed_s minDuration = 2;
1521+
elapsed_s maxDuration = 3;
1522+
}
1523+
1524+
struct PowerAdjustCapabilityStruct {
1525+
nullable PowerAdjustStruct powerAdjustCapability[] = 0;
1526+
PowerAdjustReasonEnum cause = 1;
1527+
}
1528+
15111529
struct SlotStruct {
15121530
elapsed_s minDuration = 0;
15131531
elapsed_s maxDuration = 1;
15141532
elapsed_s defaultDuration = 2;
15151533
elapsed_s elapsedSlotTime = 3;
15161534
elapsed_s remainingSlotTime = 4;
1517-
optional boolean slotIsPauseable = 5;
1535+
optional boolean slotIsPausable = 5;
15181536
optional elapsed_s minPauseDuration = 6;
15191537
optional elapsed_s maxPauseDuration = 7;
15201538
optional int16u manufacturerESAState = 8;
@@ -1530,13 +1548,13 @@ provisional cluster DeviceEnergyManagement = 152 {
15301548
}
15311549

15321550
struct ForecastStruct {
1533-
int16u forecastId = 0;
1551+
int32u forecastID = 0;
15341552
nullable int16u activeSlotNumber = 1;
15351553
epoch_s startTime = 2;
15361554
epoch_s endTime = 3;
15371555
optional nullable epoch_s earliestStartTime = 4;
15381556
optional epoch_s latestEndTime = 5;
1539-
boolean isPauseable = 6;
1557+
boolean isPausable = 6;
15401558
SlotStruct slots[] = 7;
15411559
ForecastUpdateReasonEnum forecastUpdateReason = 8;
15421560
}
@@ -1549,16 +1567,9 @@ provisional cluster DeviceEnergyManagement = 152 {
15491567
optional int8s loadControl = 4;
15501568
}
15511569

1552-
struct PowerAdjustStruct {
1553-
power_mw minPower = 0;
1554-
power_mw maxPower = 1;
1555-
elapsed_s minDuration = 2;
1556-
elapsed_s maxDuration = 3;
1557-
}
1558-
15591570
struct SlotAdjustmentStruct {
15601571
int8u slotIndex = 0;
1561-
power_mw nominalPower = 1;
1572+
optional power_mw nominalPower = 1;
15621573
elapsed_s duration = 2;
15631574
}
15641575

@@ -1583,7 +1594,7 @@ provisional cluster DeviceEnergyManagement = 152 {
15831594
readonly attribute ESAStateEnum ESAState = 2;
15841595
readonly attribute power_mw absMinPower = 3;
15851596
readonly attribute power_mw absMaxPower = 4;
1586-
readonly attribute optional nullable PowerAdjustStruct powerAdjustmentCapability[] = 5;
1597+
readonly attribute optional nullable PowerAdjustCapabilityStruct powerAdjustmentCapability = 5;
15871598
readonly attribute optional nullable ForecastStruct forecast = 6;
15881599
readonly attribute optional OptOutStateEnum optOutState = 7;
15891600
readonly attribute command_id generatedCommandList[] = 65528;
@@ -1610,7 +1621,7 @@ provisional cluster DeviceEnergyManagement = 152 {
16101621
}
16111622

16121623
request struct ModifyForecastRequestRequest {
1613-
int32u forecastId = 0;
1624+
int32u forecastID = 0;
16141625
SlotAdjustmentStruct slotAdjustments[] = 1;
16151626
AdjustmentCauseEnum cause = 2;
16161627
}

examples/energy-management-app/energy-management-common/include/DeviceEnergyManagementDelegateImpl.h

+1
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class DeviceEnergyManagementDelegate : public DeviceEnergyManagement::Delegate
6969
virtual CHIP_ERROR SetAbsMaxPower(int64_t) override;
7070
virtual CHIP_ERROR SetPowerAdjustmentCapability(Attributes::PowerAdjustmentCapability::TypeInfo::Type) override;
7171
virtual CHIP_ERROR SetForecast(DataModel::Nullable<Structs::ForecastStruct::Type>) override;
72+
virtual CHIP_ERROR SetOptOutState(OptOutStateEnum) override;
7273

7374
private:
7475
ESATypeEnum mEsaType;

examples/energy-management-app/energy-management-common/src/DeviceEnergyManagementDelegateImpl.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -364,3 +364,8 @@ CHIP_ERROR DeviceEnergyManagementDelegate::SetForecast(DataModel::Nullable<Struc
364364

365365
return CHIP_NO_ERROR;
366366
}
367+
368+
CHIP_ERROR DeviceEnergyManagementDelegate::SetOptOutState(OptOutStateEnum newValue)
369+
{
370+
return CHIP_NO_ERROR;
371+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
*
3+
* Copyright (c) 2024 Project CHIP Authors
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
#pragma once
19+
20+
#include <app-common/zap-generated/cluster-objects.h>
21+
#include <app/TestEventTriggerDelegate.h>
22+
23+
/**
24+
* @brief User handler for handling the test event trigger
25+
*
26+
* @note If TestEventTrigger is enabled, it needs to be implemented in the app
27+
*
28+
* @param eventTrigger Event trigger to handle
29+
*
30+
* @retval true on success
31+
* @retval false if error happened
32+
*/
33+
bool HandleDeviceEnergyManagementTestEventTrigger(uint64_t eventTrigger);
34+
35+
namespace chip {
36+
37+
/*
38+
* These Test EventTrigger values can be used to produce artificial DEM forecasts
39+
*
40+
* They are sent along with the enableKey (manufacturer defined secret)
41+
* in the General Diagnostic cluster TestEventTrigger command
42+
*/
43+
enum class DeviceEnergyManagementTrigger : uint64_t
44+
{
45+
// Simulate a fixed forecast power usage including one or more PowerAdjustmentStructs
46+
kPowerAdjustment = 0x0098'0000'0000'0000,
47+
// Clear the PowerAdjustment structs
48+
kPowerAdjustmentClear = 0x0098'0000'0000'0001,
49+
// Simulate user opt-out of Local Optimization
50+
kUserOptOutLocalOptimization = 0x0098'0000'0000'0002,
51+
// Simulate user opt-out of Grid Optimization
52+
kUserOptOutGridOptimization = 0x0098'0000'0000'0003,
53+
// Remove all user opt-out opting out
54+
kUserOptOutClearAll = 0x0098'0000'0000'0004,
55+
// Simulate a fixed forecast with EarliestStartTime earlier than startTime, and LatestEndTime greater than EndTime
56+
kStartTimeAdjustment = 0x0098'0000'0000'0005,
57+
// Clear the StartTimeAdjustment simulated forecast
58+
kStartTimeAdjustmentClear = 0x0098'0000'0000'0006,
59+
// Simulate a fixed forecast with one pausable slo with MinPauseDuration >1, MaxPauseDuration>1 and one non pausable slot
60+
kPausable = 0x0098'0000'0000'0007,
61+
// Simulate a moving time to the next forecast slot
62+
kPausableNextSlot = 0x0098'0000'0000'0008,
63+
// Clear the Pausable simulated forecast
64+
kPausableClear = 0x0098'0000'0000'0009,
65+
// Simulate a forecast power usage with at least 2 and at most 4 slots
66+
kForecastAdjustment = 0x0098'0000'0000'000A,
67+
// Simulate moving time to the next forecast slot
68+
kForecastAdjustmentNextSlot = 0x0098'0000'0000'000B,
69+
// Clear the forecast adjustment
70+
kForecastAdjustmentClear = 0x0098'0000'0000'000C,
71+
// Simulate a forecast power usage with at least 2 and at most 4 slots
72+
kConstraintBasedAdjustment = 0x0098'0000'0000'000D,
73+
// Clear the constraint based adjustment
74+
kConstraintBasedAdjustmentClear = 0x0098'0000'0000'000E,
75+
// Simulate a forecast with at least 1 slot
76+
kForecast = 0x0098'0000'0000'000F,
77+
// Clear the forecast
78+
kForecastClear = 0x0098'0000'0000'0010,
79+
};
80+
81+
class DeviceEnergyManagementTestEventTriggerHandler : public TestEventTriggerHandler
82+
{
83+
public:
84+
DeviceEnergyManagementTestEventTriggerHandler() {}
85+
86+
CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override
87+
{
88+
if (HandleDeviceEnergyManagementTestEventTrigger(eventTrigger))
89+
{
90+
return CHIP_NO_ERROR;
91+
}
92+
return CHIP_ERROR_INVALID_ARGUMENT;
93+
}
94+
};
95+
96+
} // namespace chip

0 commit comments

Comments
 (0)