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

Add water heater to energy management app #34886

Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
ed91e3d
Refactored file location for chip-energy-management-app. Updated esp3…
jamesharrow Aug 8, 2024
ff56e3d
Updated some all-clusters-app build and CMakeLists (linux, esp32, psoc6)
jamesharrow Aug 8, 2024
afa2ab4
Updated remaining build and CMakefiles with new folders.
jamesharrow Aug 8, 2024
aca0f92
Fixed unit tests BUILD.gn
jamesharrow Aug 8, 2024
c4a61e2
Restyled by gn
restyled-commits Aug 8, 2024
d5602aa
Missed Ameba .cmake
jamesharrow Aug 8, 2024
4b141d2
Missed all-clusters-minimal-app/esp32/main/CMakeLists.txt
jamesharrow Aug 8, 2024
df29b97
Added basic hooks to ESP32 to allow EVSE or Water Heater app
jamesharrow Aug 8, 2024
ff760e2
Merge branch 'master' into refactor-energy-management-app-folders
jamesharrow Aug 8, 2024
9c98c94
Merge branch 'refactor-energy-management-app-folders' into add-water-…
jamesharrow Aug 9, 2024
a1f02c8
Added initial WaterHeaterMain.cpp - needs rework
jamesharrow Aug 13, 2024
7bf6504
Configure runner command to use --application <dem|eevse|whm> option
PeterC1965 Aug 13, 2024
4749315
Unify the WHM and EEVSE/DEM apps
PeterC1965 Aug 13, 2024
4fb0b49
Restyled by whitespace
restyled-commits Aug 13, 2024
ae56419
Restyled by clang-format
restyled-commits Aug 13, 2024
e3872c3
Restyled by gn
restyled-commits Aug 13, 2024
cbc5066
Rename application names
PeterC1965 Aug 13, 2024
1a02f76
Merge branch 'master' into add-water-heater-to-energy-management-app
PeterC1965 Aug 14, 2024
7158574
Get ESP32 energy management app building with water-heater. Move wate…
PeterC1965 Aug 15, 2024
4ca3dcd
Get WHM triggers working
PeterC1965 Aug 16, 2024
13b5978
Get energy tests passing
PeterC1965 Aug 18, 2024
c0d2d76
Add some more build infrastructure to set the DEM feature map
PeterC1965 Aug 19, 2024
d3818f4
Address review comments from James and fix some CI tests
PeterC1965 Aug 19, 2024
96a302f
Restyled by clang-format
restyled-commits Aug 19, 2024
8ac5579
Restyled by gn
restyled-commits Aug 19, 2024
88c650d
Undo changes to Objects.py
PeterC1965 Aug 22, 2024
612f7f3
Address review from James and fix forecast subscription issues
PeterC1965 Aug 22, 2024
360832b
Address review from James
PeterC1965 Aug 22, 2024
eab22e1
Added ENERGY_REPORTING_TRIGGERS option to ESP32 and updated ESP32 REA…
jamesharrow Aug 22, 2024
8a00603
Guard against a EVSE and WHM app being simultaneously defined
PeterC1965 Aug 22, 2024
3398e97
Updated Linux README.md to highlight --application and --featureSet a…
jamesharrow Aug 22, 2024
13f5943
Fixed mis-spell
jamesharrow Aug 22, 2024
2d9abc1
Removed duplicate WaterHeaterMode::Shutdown()
jamesharrow Aug 22, 2024
b0503d4
Fixed missing free of WaterHeaterMode and made a call to both EvseMai…
jamesharrow Aug 22, 2024
6a35214
Restyled by whitespace
restyled-commits Aug 22, 2024
90b9723
Restyled by clang-format
restyled-commits Aug 22, 2024
a09a6db
Applied code review comments, attempt to fix clang build failure with…
jamesharrow Aug 22, 2024
e910999
Merge branch 'master' into add-water-heater-to-energy-management-app
jamesharrow Aug 22, 2024
726dd31
Restyled by whitespace
restyled-commits Aug 22, 2024
ce3a90f
Restyled by clang-format
restyled-commits Aug 22, 2024
9bddbfe
Get DEM and EEM tests passing when running combined app in WHM mode
PeterC1965 Aug 27, 2024
2d0f2ec
Restyled by clang-format
restyled-commits Aug 27, 2024
31e1022
Merge branch 'master' into add-water-heater-to-energy-management-app
PeterC1965 Aug 27, 2024
d0eac87
Ensure absMinPower and absMaxPower are set
PeterC1965 Aug 27, 2024
a04e2f9
Fix CI build error
PeterC1965 Aug 27, 2024
4817e43
Restyled by whitespace
restyled-commits Aug 27, 2024
c9a40d0
Restyled by clang-format
restyled-commits Aug 27, 2024
c6441d2
Fix power levels so they fit within absMinPower and absMaxPower
PeterC1965 Aug 27, 2024
440514c
Fix definition of CHIP_DEVICE_CONFIG_ENABLE_ENERGY_REPORTING_TRIGGER
PeterC1965 Aug 27, 2024
06e69a7
Merge branch 'master' into add-water-heater-to-energy-management-app
PeterC1965 Aug 27, 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
2 changes: 2 additions & 0 deletions examples/all-clusters-app/esp32/main/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ set(PRIV_INCLUDE_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/energy-management-app/energy-management-common/device-energy-management/include"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/energy-management-app/energy-management-common/energy-evse/include"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/energy-management-app/energy-management-common/energy-reporting/include"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/energy-management-app/energy-management-common/water-heater/include"
"${CMAKE_CURRENT_LIST_DIR}/include"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32"
Expand All @@ -36,6 +37,7 @@ set(SRC_DIRS_LIST
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/energy-management-app/energy-management-common/device-energy-management/src"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/energy-management-app/energy-management-common/energy-evse/src"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/energy-management-app/energy-management-common/energy-reporting/src"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/energy-management-app/energy-management-common/water-heater/src"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/providers"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/ota"
"${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/common"
Expand Down
11 changes: 6 additions & 5 deletions examples/all-clusters-app/linux/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ if (chip_enable_pw_rpc) {

source_set("chip-all-clusters-common") {
sources = [
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/WhmDelegateImpl.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/WhmInstance.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/WhmMain.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/WhmManufacturer.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/air-quality-instance.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/binding-handler.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/boolcfg-stub.cpp",
Expand Down Expand Up @@ -62,7 +58,6 @@ source_set("chip-all-clusters-common") {
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-temperature-levels.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/tcc-mode.cpp",
"${chip_root}/examples/all-clusters-app/all-clusters-common/src/water-heater-mode.cpp",
"${chip_root}/examples/all-clusters-app/linux/diagnostic-logs-provider-delegate-impl.cpp",
"${chip_root}/examples/energy-management-app/energy-management-common/common/src/EnergyTimeUtils.cpp",
"${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/src/DeviceEnergyManagementDelegateImpl.cpp",
Expand All @@ -75,6 +70,11 @@ source_set("chip-all-clusters-common") {
"${chip_root}/examples/energy-management-app/energy-management-common/energy-evse/src/EnergyEvseTargetsStore.cpp",
"${chip_root}/examples/energy-management-app/energy-management-common/energy-evse/src/energy-evse-mode.cpp",
"${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/src/ElectricalPowerMeasurementDelegate.cpp",
"${chip_root}/examples/energy-management-app/energy-management-common/water-heater/src/WhmDelegateImpl.cpp",
"${chip_root}/examples/energy-management-app/energy-management-common/water-heater/src/WhmInstance.cpp",
"${chip_root}/examples/energy-management-app/energy-management-common/water-heater/src/WhmMain.cpp",
"${chip_root}/examples/energy-management-app/energy-management-common/water-heater/src/WhmManufacturer.cpp",
"${chip_root}/examples/energy-management-app/energy-management-common/water-heater/src/water-heater-mode.cpp",
"${chip_root}/examples/thermostat/linux/thermostat-delegate-impl.cpp",
"AllClustersCommandDelegate.cpp",
"AllClustersCommandDelegate.h",
Expand Down Expand Up @@ -102,6 +102,7 @@ source_set("chip-all-clusters-common") {
"${chip_root}/examples/energy-management-app/energy-management-common/device-energy-management/include",
"${chip_root}/examples/energy-management-app/energy-management-common/energy-evse/include",
"${chip_root}/examples/energy-management-app/energy-management-common/energy-reporting/include",
"${chip_root}/examples/energy-management-app/energy-management-common/water-heater/include",
"${chip_root}/examples/thermostat/linux/include",
]

Expand Down
1 change: 0 additions & 1 deletion examples/all-clusters-app/linux/main-common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,6 @@ void ApplicationShutdown()
Clusters::WaterHeaterMode::Shutdown();

Clusters::WaterHeaterManagement::WhmApplicationShutdown();
Clusters::WaterHeaterMode::Shutdown();

if (sChipNamedPipeCommands.Stop() != CHIP_NO_ERROR)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -377,10 +377,14 @@ Status DeviceEnergyManagementDelegate::StartTimeAdjustRequest(const uint32_t req
mForecast.Value().startTime = savedStartTime;
mForecast.Value().endTime = savedEndTime;

MatterReportingAttributeChangeCallback(mEndpointId, DeviceEnergyManagement::Id, Forecast::Id);

return Status::Failure;
}
}

MatterReportingAttributeChangeCallback(mEndpointId, DeviceEnergyManagement::Id, Forecast::Id);

return Status::Success;
}

Expand Down Expand Up @@ -457,10 +461,14 @@ Status DeviceEnergyManagementDelegate::PauseRequest(const uint32_t durationS, Ad
if (cause == AdjustmentCauseEnum::kLocalOptimization)
{
mForecast.Value().forecastUpdateReason = ForecastUpdateReasonEnum::kLocalOptimization;

MatterReportingAttributeChangeCallback(mEndpointId, DeviceEnergyManagement::Id, Forecast::Id);
}
else if (cause == AdjustmentCauseEnum::kGridOptimization)
{
mForecast.Value().forecastUpdateReason = ForecastUpdateReasonEnum::kGridOptimization;

MatterReportingAttributeChangeCallback(mEndpointId, DeviceEnergyManagement::Id, Forecast::Id);
}

return Status::Success;
Expand Down Expand Up @@ -606,6 +614,8 @@ Status DeviceEnergyManagementDelegate::ResumeRequest()
// The PauseRequest has effectively been cancelled so as a result the device should
// go back to InternalOptimisation
mForecast.Value().forecastUpdateReason = ForecastUpdateReasonEnum::kInternalOptimization;

MatterReportingAttributeChangeCallback(mEndpointId, DeviceEnergyManagement::Id, Forecast::Id);
}

CHIP_ERROR err = CancelPauseRequestAndGenerateEvent(CauseEnum::kCancelled);
Expand Down Expand Up @@ -672,6 +682,8 @@ Status DeviceEnergyManagementDelegate::ModifyForecastRequest(
}

mForecast.Value().forecastID++;

MatterReportingAttributeChangeCallback(mEndpointId, DeviceEnergyManagement::Id, Forecast::Id);
}

return status;
Expand Down Expand Up @@ -725,6 +737,8 @@ Status DeviceEnergyManagementDelegate::RequestConstraintBasedForecast(

mForecast.Value().forecastID++;

MatterReportingAttributeChangeCallback(mEndpointId, DeviceEnergyManagement::Id, Forecast::Id);

status = Status::Success;
}

Expand All @@ -748,6 +762,8 @@ Status DeviceEnergyManagementDelegate::CancelRequest()

mForecast.Value().forecastUpdateReason = ForecastUpdateReasonEnum::kInternalOptimization;

MatterReportingAttributeChangeCallback(mEndpointId, DeviceEnergyManagement::Id, Forecast::Id);

/* It is expected the mpDEMManufacturerDelegate will cancel the effects of any previous adjustment
* request commands, and re-evaluate its forecast for intended operation ignoring those previous
* requests.
Expand Down Expand Up @@ -980,6 +996,8 @@ CHIP_ERROR DeviceEnergyManagementDelegate::SetOptOutState(OptOutStateEnum newVal
if ((mOptOutState == OptOutStateEnum::kOptOut) || (mOptOutState == OptOutStateEnum::kLocalOptOut))
{
mForecast.Value().forecastUpdateReason = ForecastUpdateReasonEnum::kInternalOptimization;

MatterReportingAttributeChangeCallback(mEndpointId, DeviceEnergyManagement::Id, Forecast::Id);
// Generate a new forecast with Internal Optimization
// TODO
}
Expand All @@ -988,6 +1006,8 @@ CHIP_ERROR DeviceEnergyManagementDelegate::SetOptOutState(OptOutStateEnum newVal
if ((mOptOutState == OptOutStateEnum::kOptOut) || (mOptOutState == OptOutStateEnum::kGridOptOut))
{
mForecast.Value().forecastUpdateReason = ForecastUpdateReasonEnum::kInternalOptimization;

MatterReportingAttributeChangeCallback(mEndpointId, DeviceEnergyManagement::Id, Forecast::Id);
// Generate a new forecast with Internal Optimization
// TODO
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,16 @@

#pragma once

#include <lib/core/CHIPError.h>

void EvseApplicationInit();
void EvseApplicationShutdown();

CHIP_ERROR DeviceEnergyManagementInit();
CHIP_ERROR DeviceEnergyManagementShutdown();

CHIP_ERROR EnergyMeterInit();
CHIP_ERROR EnergyMeterShutdown();

CHIP_ERROR PowerTopologyInit();
CHIP_ERROR PowerTopologyShutdown();
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ void EvseApplicationInit()

void EvseApplicationShutdown()
{
ChipLogDetail(AppServer, "Energy Management App: ApplicationShutdown()");
ChipLogDetail(AppServer, "Energy Management App (EVSE): ApplicationShutdown()");

/* Shutdown in reverse order that they were created */
EVSEManufacturerShutdown(); /* Free the EVSEManufacturer */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1737,6 +1737,67 @@ cluster ElectricalEnergyMeasurement = 145 {
readonly attribute int16u clusterRevision = 65533;
}

/** This cluster is used to allow clients to control the operation of a hot water heating appliance so that it can be used with energy management. */
provisional cluster WaterHeaterManagement = 148 {
revision 2;

enum BoostStateEnum : enum8 {
kInactive = 0;
kActive = 1;
}

bitmap Feature : bitmap32 {
kEnergyManagement = 0x1;
kTankPercent = 0x2;
}

bitmap WaterHeaterHeatSourceBitmap : bitmap8 {
kImmersionElement1 = 0x1;
kImmersionElement2 = 0x2;
kHeatPump = 0x4;
kBoiler = 0x8;
kOther = 0x10;
}

struct WaterHeaterBoostInfoStruct {
elapsed_s duration = 0;
optional boolean oneShot = 1;
optional boolean emergencyBoost = 2;
optional temperature temporarySetpoint = 3;
optional percent targetPercentage = 4;
optional percent targetReheat = 5;
}

info event BoostStarted = 0 {
WaterHeaterBoostInfoStruct boostInfo = 0;
}

info event BoostEnded = 1 {
}

readonly attribute WaterHeaterHeatSourceBitmap heaterTypes = 0;
readonly attribute WaterHeaterHeatSourceBitmap heatDemand = 1;
readonly attribute optional int16u tankVolume = 2;
readonly attribute optional energy_mwh estimatedHeatRequired = 3;
readonly attribute optional percent tankPercentage = 4;
readonly attribute BoostStateEnum boostState = 5;
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;

request struct BoostRequest {
WaterHeaterBoostInfoStruct boostInfo = 0;
}

/** Allows a client to request that the water heater is put into a Boost state. */
command access(invoke: manage) Boost(BoostRequest): DefaultSuccess = 0;
/** Allows a client to cancel an ongoing Boost operation. */
command access(invoke: manage) CancelBoost(): DefaultSuccess = 1;
}

/** 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 4;
Expand Down Expand Up @@ -2210,6 +2271,56 @@ cluster EnergyEvseMode = 157 {
command ChangeToMode(ChangeToModeRequest): ChangeToModeResponse = 0;
}

/** Attributes and commands for selecting a mode from a list of supported options. */
cluster WaterHeaterMode = 158 {
revision 1;

enum ModeTag : enum16 {
kOff = 16384;
kManual = 16385;
kTimed = 16386;
}

bitmap Feature : bitmap32 {
kOnOff = 0x1;
}

struct ModeTagStruct {
optional vendor_id mfgCode = 0;
enum16 value = 1;
}

struct ModeOptionStruct {
char_string<64> label = 0;
int8u mode = 1;
ModeTagStruct modeTags[] = 2;
}

readonly attribute ModeOptionStruct supportedModes[] = 0;
readonly attribute int8u currentMode = 1;
attribute optional nullable int8u startUpMode = 2;
jamesharrow marked this conversation as resolved.
Show resolved Hide resolved
attribute optional nullable int8u onMode = 3;
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;

request struct ChangeToModeRequest {
int8u newMode = 0;
}

response struct ChangeToModeResponse = 1 {
enum8 status = 0;
optional char_string statusText = 1;
}

/** This command is used to change device modes.
On receipt of this command the device SHALL respond with a ChangeToModeResponse command. */
command ChangeToMode(ChangeToModeRequest): ChangeToModeResponse = 0;
}

/** Attributes and commands for selecting a mode from a list of supported options. */
provisional cluster DeviceEnergyManagementMode = 159 {
revision 1;
Expand Down Expand Up @@ -2557,6 +2668,24 @@ endpoint 1 {
ram attribute clusterRevision default = 1;
}

server cluster WaterHeaterManagement {
callback attribute heaterTypes;
callback attribute heatDemand;
callback attribute tankVolume;
callback attribute estimatedHeatRequired;
callback attribute tankPercentage;
callback attribute boostState;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
callback attribute attributeList;
callback attribute featureMap;
callback attribute clusterRevision;

handle command Boost;
handle command CancelBoost;
}

server cluster DeviceEnergyManagement {
emits event PowerAdjustStart;
emits event PowerAdjustEnd;
Expand Down Expand Up @@ -2640,8 +2769,20 @@ endpoint 1 {
server cluster EnergyEvseMode {
callback attribute supportedModes;
callback attribute currentMode;
ram attribute startUpMode;
ram attribute onMode;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
callback attribute attributeList;
callback attribute featureMap;
ram attribute clusterRevision default = 1;

handle command ChangeToMode;
handle command ChangeToModeResponse;
}

server cluster WaterHeaterMode {
callback attribute supportedModes;
callback attribute currentMode;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
Expand All @@ -2656,8 +2797,6 @@ endpoint 1 {
server cluster DeviceEnergyManagementMode {
callback attribute supportedModes;
callback attribute currentMode;
ram attribute startUpMode;
ram attribute onMode;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute eventList;
Expand Down
Loading
Loading