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

Water heater management server impl #34230

Closed
Changes from 1 commit
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
cf2e8ab
Updated device-energy-management-cluster.xml and energy-evse-cluster.…
jamesharrow May 29, 2024
1b9021e
Regen_all checked in.
jamesharrow May 29, 2024
c508af5
Added missing energy-management-app.matter
jamesharrow May 29, 2024
2ed3c01
Updated with spec PR #9251 merged to master.
jamesharrow May 30, 2024
f34083f
Updated with spec PR #9266 (change ForecastId -> ForecastID)
jamesharrow May 30, 2024
824f90b
regen_all
jamesharrow May 30, 2024
6ca83b4
Removed extra entryType="PowerAdjustStruct" which causes incorrect ge…
jamesharrow Jun 3, 2024
c9c27a5
Removed extra min="-4611686018427387904" max="4611686018427387903" wh…
jamesharrow Jun 3, 2024
59c5802
Updated after regen_all
jamesharrow Jun 3, 2024
26d3030
Reverted max="86400" in RANDOMIZATION_DELAY_WINDOW which upsets some …
jamesharrow Jun 3, 2024
6ce2430
Added missing autogen'd code for DEM changes.
jamesharrow Jun 3, 2024
2380b98
Fix up compilation errors caused by change to forecastID and powerAdj…
jamesharrow Jun 3, 2024
9bd8e16
Merge branch 'upstream-master' into Update_Energy_Cluster_XML_For_1_4
jamesharrow Jun 18, 2024
482a6af
Added Water Heater Management cluster XML
jamesharrow Jun 18, 2024
f53bfeb
Added Water Heater Management to controller-clusters.zap
jamesharrow Jun 18, 2024
7e510b1
Added Water Heater Management to zap_cluster_list.json
jamesharrow Jun 18, 2024
749636e
Added Water Heater Management cluster to all-clusters-app.zap
jamesharrow Jun 18, 2024
6c7c308
Tried to add apiMaturity="provisional" to silence deprecation warning…
jamesharrow Jun 18, 2024
f5c4f62
Added all-clusters-app.matter and controller-clusters.matter after re…
jamesharrow Jun 18, 2024
81f7009
Added output from regen_all.py
jamesharrow Jun 18, 2024
61668a3
Merge branch 'master' into Update_Energy_Cluster_XML_For_1_4
jamesharrow Jun 18, 2024
df7ad2b
Updated .zap files after adding provisional flag.
jamesharrow Jun 18, 2024
aa58bed
Added Java matter controller now that apiMaturity=provisional has pop…
jamesharrow Jun 18, 2024
ad27399
Trying to remove Thread Border Router Management in controller-cluste…
jamesharrow Jun 18, 2024
50308fd
Removed water-heater-management-server for now so compilers don't try…
jamesharrow Jun 18, 2024
5330712
Reverted all-clusters-app.zap (removed Water heater). Reverted contro…
jamesharrow Jun 18, 2024
2cbeab7
updated all-clusters-app.matter after removing WaterHeaterManagement …
jamesharrow Jun 18, 2024
4944127
Candidate fix for THREAD_BORDER_ROUTER_MANAGEMENT_CLUSTER which resol…
jamesharrow Jun 18, 2024
dfb81db
Merge branch 'project-chip:master' into Update_Energy_Cluster_XML_For…
jamesharrow Jun 18, 2024
f8b35c2
Merge branch 'upstream-master' into Update_Energy_Cluster_XML_For_1_4
jamesharrow Jun 19, 2024
44441b8
Initial implementation of the water heater management server
PeterC1965 Jun 20, 2024
87a55bf
Get all-clusters-app building with water-heater-management cluster
PeterC1965 Jun 20, 2024
daab57e
Add some debug prints
PeterC1965 Jun 20, 2024
8a0f8e5
Add water-heater-management-app
PeterC1965 Jun 21, 2024
9357945
Implement TC_EWATERHTR_2_1.py
PeterC1965 Jun 22, 2024
40e4c8c
Implement TC_EWATERHTR_2_1.py
PeterC1965 Jun 22, 2024
97f2dbe
Start on WHM 2.2 + initial support for WaterHeater modes
PeterC1965 Jun 22, 2024
f8cfb75
Add support for the WaterHeaterMode cluster
PeterC1965 Jun 22, 2024
c3c19a3
Add support for the WaterHeaterMode cluster
PeterC1965 Jun 22, 2024
f1d9d45
Add support for the WaterHeaterMode cluster
PeterC1965 Jun 22, 2024
1c5c56d
Improve water heater mode implementation
PeterC1965 Jun 23, 2024
3b7e00c
Complete implementation of test TC_EWATERHTR_2_2
PeterC1965 Jun 24, 2024
542204f
Get WHM 2.2 passing
PeterC1965 Jun 24, 2024
29e7979
Get WHM test 2.3 working
PeterC1965 Jun 24, 2024
5283e9c
Check feature map
PeterC1965 Jun 24, 2024
acca32d
Start getting ESP32 target building
PeterC1965 Jun 24, 2024
3e7f6a4
Take water-heater-management out of all-clusters-app
PeterC1965 Jun 24, 2024
587f33e
Add water-heater-management app to config files and regenerate zzz files
PeterC1965 Jun 24, 2024
f26be3d
Get ESP32 WHM target building
PeterC1965 Jun 24, 2024
d72f443
Tidy ups
PeterC1965 Jun 24, 2024
ad6c1f8
Merge branch 'master' into water-heater-management-server-impl
PeterC1965 Jun 24, 2024
89d433d
Regenerate zap files
PeterC1965 Jun 24, 2024
bf3e798
Use the manufacturer object to determine heating sources and turn on/…
PeterC1965 Jun 25, 2024
275b471
Remove TODOs
PeterC1965 Jun 25, 2024
7486cc3
Bring into line with latest spec changes
PeterC1965 Jun 25, 2024
e1463a5
Tidy up python code
PeterC1965 Jun 26, 2024
bb75aa3
Initialise the WaterHeaterModeInstance
PeterC1965 Jun 26, 2024
d22e735
Fix CI tests
PeterC1965 Jun 26, 2024
8e5046b
Merge branch 'master' into water-heater-management-server-impl
PeterC1965 Jun 26, 2024
155c495
Catch up with head master + regenerate all files
PeterC1965 Jun 26, 2024
d44f3ed
Catch up with head master + regenerate all files
PeterC1965 Jun 26, 2024
54f87e5
Improve error handling
PeterC1965 Jul 4, 2024
268bd0e
Merge branch 'master' into water-heater-management-server-impl
PeterC1965 Jul 8, 2024
778f60a
Restyled by whitespace
restyled-commits Jul 8, 2024
1b35c85
Restyled by clang-format
restyled-commits Jul 8, 2024
0b9ca86
Restyled by gn
restyled-commits Jul 8, 2024
7e56303
Restyled by prettier-markdown
restyled-commits Jul 8, 2024
e53e501
Restyled by autopep8
restyled-commits Jul 8, 2024
514dc47
Restyled by isort
restyled-commits Jul 8, 2024
9083688
Enable uniqueID in the BasicInformation cluster
PeterC1965 Jul 8, 2024
678aa7f
Regenerate zap files
PeterC1965 Jul 8, 2024
e32ec37
Apply review comments from Boris
PeterC1965 Jul 16, 2024
fc90ec5
Add command line support for specifying the featureMap + fix logic in…
PeterC1965 Jul 17, 2024
588d64c
Add command line support for specifying the featureMap + fix logic in…
PeterC1965 Jul 17, 2024
7190fef
Restyled by clang-format
restyled-commits Jul 17, 2024
f8a385a
Merge branch 'master' into water-heater-management-server-impl
PeterC1965 Jul 18, 2024
eb6de20
Finish merge
PeterC1965 Jul 18, 2024
1528700
Apply code review changes
PeterC1965 Jul 18, 2024
09d01a9
Sync up with review comments
PeterC1965 Jul 21, 2024
e05568e
Return ModeBase::StatusCode::kSuccess in WaterHeaterManagementDelegat…
PeterC1965 Jul 21, 2024
b1e4164
Update from fixes done on other branches
PeterC1965 Jul 22, 2024
4929eef
Merge branch 'master' into water-heater-management-server-impl
PeterC1965 Jul 22, 2024
8e84752
Tidy up merge from master
PeterC1965 Jul 22, 2024
433d33d
Add RUNNER commands
PeterC1965 Jul 22, 2024
c33273b
Merge branch 'master' into water-heater-management-server-impl
PeterC1965 Jul 23, 2024
94909fd
Update following test script changes
PeterC1965 Jul 25, 2024
4715c98
Update following test script changes
PeterC1965 Jul 25, 2024
8ce0b33
Merge branch 'master' into water-heater-management-server-impl
PeterC1965 Jul 25, 2024
1101eea
Merge branch 'master' into water-heater-management-server-impl
PeterC1965 Jul 25, 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
Prev Previous commit
Next Next commit
Use the manufacturer object to determine heating sources and turn on/…
…off heating
PeterC1965 committed Jun 25, 2024
commit bf3e7989e08b83f1e5db53b4ead59bb2a4684341
Original file line number Diff line number Diff line change
@@ -31,6 +31,8 @@ namespace WaterHeaterManagement {

using ModeTagStructType = detail::Structs::ModeTagStruct::Type;

class WhmManufacturer;

// This is an application level delegate to handle operational state commands according to the specific business logic.
class WaterHeaterManagementDelegate : public WaterHeaterManagement::Delegate,
public ModeBase::Delegate
@@ -42,6 +44,8 @@ class WaterHeaterManagementDelegate : public WaterHeaterManagement::Delegate,

void SetWaterHeaterManagementInstance(WaterHeaterManagement::Instance & instance);

void SetWhmManufacturer(WhmManufacturer & whmManufacturer);

/*********************************************************************************
*
* Methods implementing the WaterHeaterManagement::Delegate interace
@@ -225,6 +229,9 @@ class WaterHeaterManagementDelegate : public WaterHeaterManagement::Delegate,
// Need the following so can determine which features are supported
WaterHeaterManagement::Instance *mpWhmInstance;

// Pointer to the manufacturer specific object which understand the hardware
WhmManufacturer * mpWhmManufacturer;

// Target water temperature in 100ths of a C
uint16_t mTargetWaterTemperature;

Original file line number Diff line number Diff line change
@@ -62,6 +62,21 @@ class WhmManufacturer
*/
CHIP_ERROR Shutdown();

/**
* @brief Called to determine which heating sources to use,
*/
BitMask<WaterHeaterDemandBitmap> DetermineHeatingSources();

/**
* @brief Turn the heating of the water tank on.
*/
void TurnHeatingOn();

/**
* @brief Turn the heating of the water tank off.
*/
void TurnHeatingOff();

private:
WaterHeaterManagementInstance * mWhmInstance;
};
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@
#include <app/clusters/water-heater-management-server/water-heater-management-server.h>

#include <WhmDelegate.h>
#include <WhmManufacturer.h>

using namespace chip;
using namespace chip::app;
@@ -28,6 +29,7 @@ using Protocols::InteractionModel::Status;

WaterHeaterManagementDelegate::WaterHeaterManagementDelegate(EndpointId clustersEndpoint):
mpWhmInstance(nullptr),
mpWhmManufacturer(nullptr),
mBoostTargetTemperatureReached(false),
mWaterHeaterModeInstance(this, clustersEndpoint, WaterHeaterMode::Id, 0),
mTankVolume(0),
@@ -49,6 +51,11 @@ void WaterHeaterManagementDelegate::SetWaterHeaterManagementInstance(WaterHeater
}
}

void WaterHeaterManagementDelegate::SetWhmManufacturer(WhmManufacturer & whmManufacturer)
{
mpWhmManufacturer = &whmManufacturer;
}

/*********************************************************************************
*
* Methods implementing the WaterHeaterManagement::Delegate interace
@@ -418,31 +425,19 @@ void WaterHeaterManagementDelegate::CheckIfHeatNeedsToBeTurnedOnOrOff()
// If a boost command is in progress or in manual mode, find a heating source and "turn it on".
if (mBoostState == BoostStateEnum::kActive || mode == ModeManual)
{
// Look through the heaterTypes attribute for a valid source
bool found = false;
uint8_t rawBitmask = mHeaterTypes.Raw();
uint8_t bit = 0;
while (rawBitmask != 0 && !found)
if (mpWhmManufacturer != nullptr)
{
if (rawBitmask & 1)
{
found = true;
}
else
{
bit++;
rawBitmask >>= 1;
}
}
// Find out from the manufacturer object the heating sources to use.
BitMask<WaterHeaterDemandBitmap> heaterDemand = mpWhmManufacturer->DetermineHeatingSources();

if (found)
{
// Found a source - use it to turn the heating on
SetHeatDemand(BitMask<WaterHeaterDemandBitmap>(1 << bit));
SetHeatDemand(heaterDemand);

// And turn the heating of the water tank on.
mpWhmManufacturer->TurnHeatingOn();
}
else
{
ChipLogError(Zcl, "WaterHeaterManagementDelegate::CheckIfHeatNeedsToBeTurnedOnOrOff Failed to find heaterType");
ChipLogError(Zcl, "WaterHeaterManagementDelegate::CheckIfHeatNeedsToBeTurnedOnOrOff: Failed as mpWhmManufacturer == nullptr");
}
}
}
@@ -478,6 +473,16 @@ void WaterHeaterManagementDelegate::CheckIfHeatNeedsToBeTurnedOnOrOff()

DeviceLayer::SystemLayer().CancelTimer(BoostTimerExpiry, this);
}

// Turn the heating off
if (mpWhmManufacturer != nullptr)
{
mpWhmManufacturer->TurnHeatingOff();
}
else
{
ChipLogError(Zcl, "WaterHeaterManagementDelegate::CheckIfHeatNeedsToBeTurnedOnOrOff: Failed to turn the heating off as mpWhmManufacturer == nullptr");
}
}
}

Original file line number Diff line number Diff line change
@@ -147,6 +147,9 @@ CHIP_ERROR WhmManufacturerInit()
return err;
}

// Let the WhmDelegate know about the WhmManufacturer object.
gWhmDelegate->SetWhmManufacturer(*gWhmManufacturer);

return CHIP_NO_ERROR;
}

Original file line number Diff line number Diff line change
@@ -44,6 +44,62 @@ CHIP_ERROR WhmManufacturer::Shutdown()
return CHIP_NO_ERROR;
}

BitMask<WaterHeaterDemandBitmap> WhmManufacturer::DetermineHeatingSources()
{
WaterHeaterManagementDelegate * dg = GetWhmManufacturer()->GetWhmDelegate();
if (dg == nullptr)
{
ChipLogError(AppServer, "WhmDelegate is not initialized");
return BitMask<WaterHeaterDemandBitmap>(0);
}

// A list of valid heaterTypes
uint8_t waterHeaterTypeValues[] =
{
static_cast<uint8_t>(WaterHeaterTypeBitmap::kImmersionElement1),
static_cast<uint8_t>(WaterHeaterTypeBitmap::kImmersionElement2),
static_cast<uint8_t>(WaterHeaterTypeBitmap::kHeatPump),
static_cast<uint8_t>(WaterHeaterTypeBitmap::kBoiler),
static_cast<uint8_t>(WaterHeaterTypeBitmap::kOther),
};

// The corresponding list of valid headerDemands
uint8_t waterHeaterDemandValues[] =
{
static_cast<uint8_t>(WaterHeaterTypeBitmap::kImmersionElement1),
static_cast<uint8_t>(WaterHeaterTypeBitmap::kImmersionElement2),
static_cast<uint8_t>(WaterHeaterTypeBitmap::kHeatPump),
static_cast<uint8_t>(WaterHeaterTypeBitmap::kBoiler),
static_cast<uint8_t>(WaterHeaterTypeBitmap::kOther),
};

// Iterate across the valid waterHeaterTypes seeing which heating sources are available based on heaterTypes.
// Set the corresponding bit in the heaterDemand bitmap.
BitMask<WaterHeaterTypeBitmap> heaterTypes = dg->GetHeaterTypes();

uint8_t heaterDemandMask = 0;
for (uint8_t idx = 0; idx < sizeof(waterHeaterTypeValues) / sizeof(waterHeaterTypeValues[0]); idx++)
{
// Is this heating source being used?
if (heaterTypes.Raw() & waterHeaterTypeValues[idx])
{
heaterDemandMask |= waterHeaterDemandValues[idx];
}
}

return BitMask<WaterHeaterDemandBitmap>(heaterDemandMask);
}

void WhmManufacturer::TurnHeatingOn()
{
ChipLogProgress(AppServer, "WhmManufacturer::TurnHeatingOn");
}

void WhmManufacturer::TurnHeatingOff()
{
ChipLogProgress(AppServer, "WhmManufacturer::TurnHeatingOff");
}

WaterHeaterManagementDelegate * GetWhmDelegate()
{
WhmManufacturer * mn = GetWhmManufacturer();