Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/energypreferences #31612

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
a049a1a
Adding the Energy Preferences XML
drempelg Oct 25, 2023
11b12c0
Merge branch 'project-chip:master' into feature/energypreferences
drempelg Dec 11, 2023
af64d8b
Added just the xml and regenerated. No implementations yet as
drempelg Dec 11, 2023
ca5bf2c
Merge branch 'master' into feature/energypreferences-xml
drempelg Dec 11, 2023
245acd0
Merge branch 'master' into feature/energypreferences-xml
drempelg Dec 13, 2023
4b017cd
Merge branch 'master' into feature/energypreferences-xml
drempelg Dec 14, 2023
135cfdd
Merge branch 'master' into feature/energypreferences-xml
drempelg Dec 14, 2023
09c7c06
regen
drempelg Dec 14, 2023
53883db
Merge branch 'master' into feature/energypreferences
drempelg Dec 14, 2023
39bcac0
Merge branch 'feature/energypreferences-xml' into feature/energyprefe…
drempelg Dec 14, 2023
99c8a68
put the cluster back into all-clusters after merge.
drempelg Dec 14, 2023
2bf0159
Apply suggestions from code review
drempelg Dec 18, 2023
51a5018
Merge branch 'master' into feature/energypreferences-xml
drempelg Dec 18, 2023
d9cd2c9
regenerate
drempelg Dec 18, 2023
aa37c05
Merge branch 'master' into feature/energypreferences-xml
drempelg Dec 18, 2023
a5a62db
Merge branch 'master' into feature/energypreferences-xml
drempelg Dec 19, 2023
9357e4a
Merge branch 'feature/energypreferences-xml' into feature/energyprefe…
drempelg Dec 19, 2023
c660978
Merge branch 'master' into feature/energypreferences
drempelg Jan 8, 2024
f2088df
Merge branch 'master' into feature/energypreferences
drempelg Jan 8, 2024
67fb16a
Merge branch 'project-chip:master' into feature/energypreferences
drempelg Jan 12, 2024
9258bb3
Finished up impl for energy-preferences
drempelg Jan 13, 2024
1dfa2b0
Merge branch 'project-chip:master' into feature/energypreferences
drempelg Jan 13, 2024
480ce86
Added some error checking for features, and constraint checking.
drempelg Jan 13, 2024
86affa4
Restyled by whitespace
restyled-commits Jan 13, 2024
459b58e
Restyled by clang-format
restyled-commits Jan 13, 2024
1f272c6
Fixed copy paste bug
drempelg Jan 13, 2024
2f51705
Removed some unecessary changes and a comment.
drempelg Jan 13, 2024
2369426
initialize the delegate pointer
drempelg Jan 13, 2024
377b3af
Merge branch 'master' into feature/energypreferences
drempelg Jan 17, 2024
8e931fe
Merge branch 'master' into feature/energypreferences
drempelg Jan 17, 2024
1ee1d5d
Merge branch 'master' into feature/energypreferences
drempelg Jan 19, 2024
f43c872
Merge branch 'feature/energypreferences' of https://github.com/drempe…
drempelg Jan 22, 2024
66e24ad
Put the cluster back in the all-clusters app after the merge
drempelg Jan 22, 2024
3848b7d
Fixed minor issues from review
drempelg Jan 22, 2024
91f18ad
Restyled by whitespace
restyled-commits Jan 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4332,6 +4332,40 @@ provisional cluster EnergyEvse = 153 {
timed command ClearTargets(): DefaultSuccess = 7;
}

/** This cluster provides an interface to specify preferences for how devices should consume energy. */
cluster EnergyPreference = 155 {
revision 1;

enum EnergyPriorityEnum : enum8 {
kComfort = 0;
kSpeed = 1;
kEfficiency = 2;
kWaterConsumption = 3;
}

bitmap Feature : bitmap32 {
kEnergyBalance = 0x1;
kLowPowerModeSensitivity = 0x2;
}

struct BalanceStruct {
percent step = 0;
optional char_string<64> label = 1;
}

readonly attribute optional BalanceStruct energyBalances[] = 0;
attribute optional int8u currentEnergyBalance = 1;
readonly attribute optional EnergyPriorityEnum energyPriorities[] = 2;
readonly attribute optional BalanceStruct lowPowerModeSensitivities[] = 3;
attribute optional int8u currentLowPowerModeSensitivity = 4;
readonly attribute command_id generatedCommandList[] = 65528;
readonly attribute command_id acceptedCommandList[] = 65529;
readonly attribute event_id eventList[] = 65530;
readonly attribute attrib_id attributeList[] = 65531;
readonly attribute bitmap32 featureMap = 65532;
readonly attribute int16u clusterRevision = 65533;
}

/** Attributes and commands for selecting a mode from a list of supported options. */
provisional cluster EnergyEvseMode = 157 {
revision 1;
Expand Down Expand Up @@ -8160,6 +8194,20 @@ endpoint 1 {
handle command ClearTargets;
}

server cluster EnergyPreference {
callback attribute energyBalances;
ram attribute currentEnergyBalance;
callback attribute energyPriorities;
callback attribute lowPowerModeSensitivities;
ram attribute currentLowPowerModeSensitivity;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
callback attribute attributeList;
ram attribute featureMap default = 3;
ram attribute clusterRevision default = 1;
}

server cluster EnergyEvseMode {
callback attribute supportedModes;
callback attribute currentMode;
Expand Down
186 changes: 186 additions & 0 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -14035,6 +14035,192 @@
}
]
},
{
"name": "Energy Preference",
"code": 155,
"mfgCode": null,
"define": "ENERGY_PREFERENCE_CLUSTER",
"side": "server",
"enabled": 1,
"attributes": [
{
"name": "EnergyBalances",
"code": 0,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "CurrentEnergyBalance",
"code": 1,
"mfgCode": null,
"side": "server",
"type": "int8u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "EnergyPriorities",
"code": 2,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "LowPowerModeSensitivities",
"code": 3,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "CurrentLowPowerModeSensitivity",
"code": 4,
"mfgCode": null,
"side": "server",
"type": "int8u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "GeneratedCommandList",
"code": 65528,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "AcceptedCommandList",
"code": 65529,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "EventList",
"code": 65530,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "AttributeList",
"code": 65531,
"mfgCode": null,
"side": "server",
"type": "array",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": null,
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "FeatureMap",
"code": 65532,
"mfgCode": null,
"side": "server",
"type": "bitmap32",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "3",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "ClusterRevision",
"code": 65533,
"mfgCode": null,
"side": "server",
"type": "int16u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "1",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
"reportableChange": 0
}
]
},
{
"name": "Window Covering",
"code": 258,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
#include <app/clusters/energy-preference-server/energy-preference-server.h>

using namespace chip;
using namespace chip::app::Clusters::EnergyPreference;
using namespace chip::app::Clusters::EnergyPreference::Structs;

static BalanceStruct::Type gsEnergyBalances[] = {
{ .step = 0, .label = Optional<chip::CharSpan>("Efficient"_span) },
{ .step = 50, .label = Optional<chip::CharSpan>() },
{ .step = 100, .label = Optional<chip::CharSpan>("Comfort"_span) },
};

static BalanceStruct::Type gsPowerBalances[] = {
{ .step = 0, .label = Optional<chip::CharSpan>("1 Minute"_span) },
{ .step = 12, .label = Optional<chip::CharSpan>("5 Minutes"_span) },
{ .step = 24, .label = Optional<chip::CharSpan>("10 Minutes"_span) },
{ .step = 36, .label = Optional<chip::CharSpan>("15 Minutes"_span) },
{ .step = 48, .label = Optional<chip::CharSpan>("20 Minutes"_span) },
{ .step = 60, .label = Optional<chip::CharSpan>("25 Minutes"_span) },
{ .step = 70, .label = Optional<chip::CharSpan>("30 Minutes"_span) },
{ .step = 80, .label = Optional<chip::CharSpan>("60 Minutes"_span) },
{ .step = 90, .label = Optional<chip::CharSpan>("120 Minutes"_span) },
{ .step = 100, .label = Optional<chip::CharSpan>("Never"_span) },
};

// assumes it'll be the only delegate for it's lifetime.
struct EPrefDelegate : public EnergyPreferenceDelegate
{
EPrefDelegate();
virtual ~EPrefDelegate();

CHIP_ERROR GetEnergyBalanceAtIndex(chip::EndpointId aEndpoint, size_t aIndex, BalanceStruct::Type & balance) override;
CHIP_ERROR GetEnergyPriorityAtIndex(chip::EndpointId aEndpoint, size_t aIndex, EnergyPriorityEnum & priority) override;
CHIP_ERROR GetLowPowerModeSensitivityAtIndex(chip::EndpointId aEndpoint, size_t aIndex, BalanceStruct::Type & balance) override;

size_t GetNumEnergyBalances(chip::EndpointId aEndpoint) override;
size_t GetNumLowPowerModes(chip::EndpointId aEndpoint) override;
};

EPrefDelegate::EPrefDelegate() : EnergyPreferenceDelegate()
{
VerifyOrDie(GetMatterEnergyPreferencesDelegate() == nullptr);
SetMatterEnergyPreferencesDelegate(this);
}

EPrefDelegate::~EPrefDelegate()
{
VerifyOrDie(GetMatterEnergyPreferencesDelegate() == this);
SetMatterEnergyPreferencesDelegate(nullptr);
}

size_t EPrefDelegate::GetNumEnergyBalances(chip::EndpointId aEndpoint)
{
return (ArraySize(gsEnergyBalances));
}

size_t EPrefDelegate::GetNumLowPowerModes(chip::EndpointId aEndpoint)
{
return (ArraySize(gsEnergyBalances));
}

CHIP_ERROR
EPrefDelegate::GetEnergyBalanceAtIndex(chip::EndpointId aEndpoint, size_t aIndex, BalanceStruct::Type & balance)
{
if (aIndex < GetNumEnergyBalances(aEndpoint))
{
balance = gsEnergyBalances[aIndex];
return CHIP_NO_ERROR;
}
return CHIP_ERROR_NOT_FOUND;
}

CHIP_ERROR
EPrefDelegate::GetEnergyPriorityAtIndex(chip::EndpointId aEndpoint, size_t aIndex, EnergyPriorityEnum & priority)
{
static EnergyPriorityEnum priorities[] = { EnergyPriorityEnum::kEfficiency, EnergyPriorityEnum::kComfort };

if (aIndex < (sizeof(priorities) / sizeof(priorities[0])))
{
priority = priorities[aIndex];
return CHIP_NO_ERROR;
}

return CHIP_ERROR_NOT_FOUND;
}

CHIP_ERROR
EPrefDelegate::GetLowPowerModeSensitivityAtIndex(chip::EndpointId aEndpoint, size_t aIndex, BalanceStruct::Type & balance)
{
if (aIndex < GetNumLowPowerModes(aEndpoint))
{
balance = gsPowerBalances[aIndex];
return CHIP_NO_ERROR;
}

return CHIP_ERROR_NOT_FOUND;
}

static EPrefDelegate gsDelegate;
1 change: 1 addition & 0 deletions examples/all-clusters-app/ameba/chip_main.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ list(
${chip_dir}/examples/all-clusters-app/all-clusters-common/src/concentration-measurement-instances.cpp
${chip_dir}/examples/all-clusters-app/all-clusters-common/src/device-energy-management-stub.cpp
${chip_dir}/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp
${chip_dir}/examples/all-clusters-app/all-clusters-common/src/energy-preference-delegate.cpp
${chip_dir}/examples/all-clusters-app/all-clusters-common/src/fan-stub.cpp
${chip_dir}/examples/all-clusters-app/all-clusters-common/src/oven-modes.cpp
${chip_dir}/examples/all-clusters-app/all-clusters-common/src/laundry-washer-controls-delegate-impl.cpp
Expand Down
5 changes: 4 additions & 1 deletion examples/all-clusters-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,11 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/time-synchronization-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/valve-configuration-and-control-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/dishwasher-alarm-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/laundry-washer-controls-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/laundry-washer-controls-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/laundry-washer-controls-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/laundry-dryer-controls-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/all-clusters-app/all-clusters-common/src"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/energy-preference-server"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/electrical-energy-measurement-server"
)

Expand Down
1 change: 1 addition & 0 deletions examples/all-clusters-app/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ source_set("chip-all-clusters-common") {
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/dishwasher-alarm-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/dishwasher-mode.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/energy-evse-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/energy-preference-delegate.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/fan-stub.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/laundry-dryer-controls-delegate-impl.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/laundry-washer-controls-delegate-impl.cpp",
Expand Down
Loading
Loading