Skip to content

Commit 84b2a86

Browse files
committed
Merge branch 'cluster/whtr_mode' into 'main'
components/esp-matter: Add Water Heater Mode cluster See merge request app-frameworks/esp-matter!937
2 parents 55981f7 + 174ca01 commit 84b2a86

6 files changed

+61
-0
lines changed

components/esp_matter/esp_matter_cluster.cpp

+39
Original file line numberDiff line numberDiff line change
@@ -3612,6 +3612,45 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_
36123612

36133613
} /* water_heater_management */
36143614

3615+
namespace water_heater_mode {
3616+
const function_generic_t *function_list = NULL;
3617+
const int function_flags = CLUSTER_FLAG_NONE;
3618+
3619+
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
3620+
{
3621+
cluster_t *cluster = cluster::create(endpoint, WaterHeaterMode::Id, flags);
3622+
if (!cluster) {
3623+
ESP_LOGE(TAG, "Could not create cluster");
3624+
return NULL;
3625+
}
3626+
3627+
if (flags & CLUSTER_FLAG_SERVER) {
3628+
if (config && config -> delegate != nullptr) {
3629+
static const auto delegate_init_cb = WaterHeaterModeDelegateInitCB;
3630+
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
3631+
}
3632+
add_function_list(cluster, function_list, function_flags);
3633+
3634+
/* Attributes managed internally */
3635+
global::attribute::create_feature_map(cluster, 0);
3636+
mode_base::attribute::create_supported_modes(cluster, NULL, 0, 0);
3637+
3638+
/* Attributes not managed internally */
3639+
global::attribute::create_cluster_revision(cluster, cluster_revision);
3640+
if (config) {
3641+
mode_base::attribute::create_current_mode(cluster, config->current_mode);
3642+
} else {
3643+
ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes.");
3644+
}
3645+
}
3646+
3647+
/* Commands */
3648+
mode_base::command::create_change_to_mode(cluster);
3649+
3650+
return cluster;
3651+
}
3652+
} /* water_heater_mode */
3653+
36153654
// namespace binary_input_basic {
36163655
// // ToDo
36173656
// } /* binary_input_basic */

components/esp_matter/esp_matter_cluster.h

+10
Original file line numberDiff line numberDiff line change
@@ -920,5 +920,15 @@ typedef struct config {
920920
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags, uint32_t features);
921921
} /* water_heater_management */
922922

923+
namespace water_heater_mode {
924+
typedef struct config {
925+
uint8_t current_mode;
926+
void *delegate;
927+
config() : current_mode(0), delegate(nullptr) {}
928+
} config_t;
929+
930+
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
931+
} /* water_heater_mode */
932+
923933
} /* cluster */
924934
} /* esp_matter */

components/esp_matter/esp_matter_delegate_callbacks.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,11 @@ void RvcCleanModeDelegateInitCB(void *delegate, uint16_t endpoint_id)
9797
InitModeDelegate(delegate, endpoint_id, RvcCleanMode::Id);
9898
}
9999

100+
void WaterHeaterModeDelegateInitCB(void *delegate, uint16_t endpoint_id)
101+
{
102+
InitModeDelegate(delegate, endpoint_id, WaterHeaterMode::Id);
103+
}
104+
100105
void EnergyEvseModeDelegateInitCB(void *delegate, uint16_t endpoint_id)
101106
{
102107
InitModeDelegate(delegate, endpoint_id, EnergyEvseMode::Id);

components/esp_matter/esp_matter_delegate_callbacks.h

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ void DishWasherModeDelegateInitCB(void *delegate, uint16_t endpoint_id);
2222
void RefrigeratorAndTCCModeDelegateInitCB(void *delegate, uint16_t endpoint_id);
2323
void RvcRunModeDelegateInitCB(void *delegate, uint16_t endpoint_id);
2424
void RvcCleanModeDelegateInitCB(void *delegate, uint16_t endpoint_id);
25+
void WaterHeaterModeDelegateInitCB(void *delegate, uint16_t endpoint_id);
2526
void EnergyEvseModeDelegateInitCB(void *delegate, uint16_t endpoint_id);
2627
void EnergyEvseDelegateInitCB(void *delegate, uint16_t endpoint_id);
2728
void MicrowaveOvenModeDelegateInitCB(void *delegate, uint16_t endpoint_id);

components/esp_matter/private/esp_matter_cluster_revisions.h

+4
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,10 @@ namespace rvc_clean_mode {
315315
constexpr uint16_t cluster_revision = 1;
316316
} // namespace rvc_clean_mode
317317

318+
namespace water_heater_mode {
319+
constexpr uint16_t cluster_revision = 1;
320+
} // namespace water_heater_mode
321+
318322
namespace microwave_oven_mode {
319323
constexpr uint16_t cluster_revision = 1;
320324
} // namespace microwave_oven_mode

docs/en/app_guide.rst

+2
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ ModeWaterHeater, ModeRefrigerator, ModeLaundryWasher and ModeMicrowaveOven.
6363
, `Energy Evse Mode`_
6464
, `Microwave Oven Mode`_
6565
, `Device Energy Management Mode`_
66+
, `Water Heater Mode`_
6667

6768
9.1.2 Energy Evse Cluster
6869
-------------------------
@@ -243,6 +244,7 @@ ModeWaterHeater, ModeRefrigerator, ModeLaundryWasher and ModeMicrowaveOven.
243244
.. _`Energy Evse Mode`: https://github.com/espressif/connectedhomeip/blob/ea679d2dc674f576f4d391d1d71af1489010e580/examples/energy-management-app/energy-management-common/energy-evse/include/energy-evse-modes.h
244245
.. _`Microwave Oven Mode`: https://github.com/espressif/connectedhomeip/blob/ea679d2dc674f576f4d391d1d71af1489010e580/examples/all-clusters-app/all-clusters-common/include/microwave-oven-mode.h
245246
.. _`Device Energy Management Mode`: https://github.com/espressif/connectedhomeip/blob/ea679d2dc674f576f4d391d1d71af1489010e580/examples/energy-management-app/energy-management-common/device-energy-management/include/device-energy-management-modes.h
247+
.. _`Water Heater Mode`: https://github.com/espressif/connectedhomeip/blob/ea679d2dc674f576f4d391d1d71af1489010e580/examples/energy-management-app/energy-management-common/water-heater/include/water-heater-mode.h
246248
.. _`Energy Evse`: https://github.com/espressif/connectedhomeip/blob/ea679d2dc674f576f4d391d1d71af1489010e580/src/app/clusters/energy-evse-server/energy-evse-server.h
247249
.. _`Energy Evse Delegate`: https://github.com/espressif/connectedhomeip/blob/ea679d2dc674f576f4d391d1d71af1489010e580/examples/energy-management-app/energy-management-common/energy-evse/include/EnergyEvseDelegateImpl.h
248250
.. _`Operational State`: https://github.com/espressif/connectedhomeip/blob/ea679d2dc674f576f4d391d1d71af1489010e580/src/app/clusters/operational-state-server/operational-state-server.h

0 commit comments

Comments
 (0)