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 all 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/thermostat-common/src/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/thermostat-common/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
@@ -0,0 +1,23 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
* 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.
*/

#pragma once

#include <DeviceEnergyManagementDelegateImpl.h>

chip::app::Clusters::DeviceEnergyManagement::DeviceEnergyManagementDelegate * GetDEMDelegate();
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* limitations under the License.
*/

#include <DEMDelegate.h>
#include <DeviceEnergyManagementDelegateImpl.h>
#include <EVSEManufacturerImpl.h>
#include <app/clusters/device-energy-management-server/DeviceEnergyManagementTestEventTriggerHandler.h>
Expand All @@ -41,16 +42,6 @@ static chip::app::Clusters::DeviceEnergyManagement::Structs::PowerAdjustCapabili
static chip::app::DataModel::Nullable<chip::app::Clusters::DeviceEnergyManagement::Structs::PowerAdjustCapabilityStruct::Type>
sPowerAdjustmentCapability;

DeviceEnergyManagementDelegate * GetDEMDelegate()
{
EVSEManufacturer * mn = GetEvseManufacturer();
VerifyOrDieWithMsg(mn != nullptr, AppServer, "EVSEManufacturer is null");
DeviceEnergyManagementDelegate * dg = mn->GetDEMDelegate();
VerifyOrDieWithMsg(dg != nullptr, AppServer, "DEM Delegate is null");

return dg;
}

CHIP_ERROR ConfigureForecast(uint16_t numSlots)
{
uint32_t chipEpoch = 0;
Expand Down Expand Up @@ -92,9 +83,9 @@ CHIP_ERROR ConfigureForecast(uint16_t numSlots)

if (GetDEMDelegate()->HasFeature(DeviceEnergyManagement::Feature::kPowerForecastReporting))
{
sSlots[0].nominalPower.SetValue(1500);
sSlots[0].minPower.SetValue(1000);
sSlots[0].maxPower.SetValue(2000);
sSlots[0].nominalPower.SetValue(2500000);
sSlots[0].minPower.SetValue(1200000);
sSlots[0].maxPower.SetValue(7600000);
}

sSlots[0].nominalEnergy.SetValue(2000);
Expand All @@ -119,9 +110,9 @@ CHIP_ERROR ConfigureForecast(uint16_t numSlots)

if (GetDEMDelegate()->HasFeature(DeviceEnergyManagement::Feature::kPowerForecastReporting))
{
sSlots[slotNo].nominalPower.SetValue(2 * sSlots[slotNo - 1].nominalPower.Value());
sSlots[slotNo].minPower.SetValue(2 * sSlots[slotNo - 1].minPower.Value());
sSlots[slotNo].maxPower.SetValue(2 * sSlots[slotNo - 1].maxPower.Value());
sSlots[slotNo].nominalPower.SetValue(sSlots[slotNo - 1].nominalPower.Value());
sSlots[slotNo].minPower.SetValue(sSlots[slotNo - 1].minPower.Value());
sSlots[slotNo].maxPower.SetValue(sSlots[slotNo - 1].maxPower.Value());

sSlots[slotNo].nominalEnergy.SetValue(2 * sSlots[slotNo - 1].nominalEnergy.Value());
}
Expand All @@ -134,10 +125,7 @@ CHIP_ERROR ConfigureForecast(uint16_t numSlots)

sForecastStruct.slots = DataModel::List<const DeviceEnergyManagement::Structs::SlotStruct::Type>(sSlots, numSlots);

EVSEManufacturer * mn = GetEvseManufacturer();
mn->GetDEMDelegate()->SetForecast(DataModel::MakeNullable(sForecastStruct));
mn->GetDEMDelegate()->SetAbsMinPower(1000);
mn->GetDEMDelegate()->SetAbsMaxPower(256 * 2000 * 1000);
GetDEMDelegate()->SetForecast(DataModel::MakeNullable(sForecastStruct));

return 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 @@ -70,6 +70,10 @@ CHIP_ERROR EVSEManufacturer::Init()
/* For Device Energy Management we need the ESA to be Online and ready to accept commands */
dem->SetESAState(ESAStateEnum::kOnline);

// Set the abs min and max power
dem->SetAbsMinPower(1200000); // 1.2KW
dem->SetAbsMaxPower(7600000); // 7.6KW

/*
* This is an example implementation for manufacturers to consider
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ EVSEManufacturer * EnergyEvse::GetEvseManufacturer()
return gEvseManufacturer.get();
}

DeviceEnergyManagement::DeviceEnergyManagementDelegate * GetDEMDelegate()
{
VerifyOrDieWithMsg(gDEMDelegate.get() != nullptr, AppServer, "DEM Delegate is null");

return gDEMDelegate.get();
}

/*
* @brief Creates a Delegate and Instance for DEM
*
Expand Down Expand Up @@ -472,7 +479,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
Loading
Loading