Skip to content

Commit

Permalink
Merge branch 'device/water_heater' into 'main'
Browse files Browse the repository at this point in the history
components/esp-matter: Add Water Heater device type

See merge request app-frameworks/esp-matter!950
  • Loading branch information
dhrishi committed Nov 27, 2024
2 parents d710b47 + ddbc6e2 commit af22b40
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 0 deletions.
1 change: 1 addition & 0 deletions SUPPORTED_DEVICE_TYPES.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ i. Appliances

j. Energy
1. EVSE (Electric Vehicle Supply Equipment)
2. Water Heater

k. Network Infrastructure
1. Thread Border Router
33 changes: 33 additions & 0 deletions components/esp_matter/esp_matter_endpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2017,6 +2017,39 @@ esp_err_t add(endpoint_t *endpoint, config_t *config)
}
} /* mounted_dimmable_load_control */

namespace water_heater {
uint32_t get_device_type_id()
{
return ESP_MATTER_WATER_HEATER_DEVICE_TYPE_ID;
}

uint8_t get_device_type_version()
{
return ESP_MATTER_WATER_HEATER_DEVICE_TYPE_VERSION;
}

endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data)
{
return common::create<config_t>(node, config, flags, priv_data, add);
}

esp_err_t add(endpoint_t *endpoint, config_t *config)
{
VerifyOrReturnError(endpoint != nullptr, ESP_ERR_INVALID_ARG, ESP_LOGE(TAG, "Endpoint cannot be NULL"));
esp_err_t err = add_device_type(endpoint, get_device_type_id(), get_device_type_version());
if (err != ESP_OK) {
ESP_LOGE(TAG, "Failed to add device type id:%" PRIu32 ",err: %d", get_device_type_id(), err);
return err;
}

cluster::thermostat::create(endpoint, &(config->thermostat), CLUSTER_FLAG_SERVER, cluster::thermostat::feature::heating::get_id());
water_heater_management::create(endpoint, &(config->water_heater_management), CLUSTER_FLAG_SERVER, ESP_MATTER_NONE_FEATURE_ID);
water_heater_mode::create(endpoint, &(config->water_heater_mode), CLUSTER_FLAG_SERVER);

return ESP_OK;
}
} /* water_heater */

} /* endpoint */

namespace node {
Expand Down
16 changes: 16 additions & 0 deletions components/esp_matter/esp_matter_endpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@
#define ESP_MATTER_DEVICE_ENERGY_MANAGEMENT_DEVICE_TYPE_VERSION 2
#define ESP_MATTER_SECONDARY_NETWORK_INTERFACE_DEVICE_TYPE_ID 0x0019
#define ESP_MATTER_SECONDARY_NETWORK_INTERFACE_DEVICE_TYPE_VERSION 1
#define ESP_MATTER_WATER_HEATER_DEVICE_TYPE_ID 0x050F
#define ESP_MATTER_WATER_HEATER_DEVICE_TYPE_VERSION 1

#define ESP_MATTER_THREAD_BORDER_ROUTER_DEVICE_TYPE_ID 0x0091
#define ESP_MATTER_THREAD_BORDER_ROUTER_DEVICE_TYPE_VERSION 1
Expand Down Expand Up @@ -828,6 +830,20 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat
esp_err_t add(endpoint_t *endpoint, config_t *config);
} /** mounted_dimmable_load_control **/

namespace water_heater {
typedef struct config {
cluster::descriptor::config_t descriptor;
cluster::thermostat::config_t thermostat;
cluster::water_heater_management::config_t water_heater_management;
cluster::water_heater_mode::config_t water_heater_mode;
} config_t;

uint32_t get_device_type_id();
uint8_t get_device_type_version();
endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data);
esp_err_t add(endpoint_t *endpoint, config_t *config);
} /* water_heater */

} /* endpoint */

namespace node {
Expand Down
2 changes: 2 additions & 0 deletions examples/all_device_types_app/main/device_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ enum device_type_enum {
ESP_MATTER_THREAD_BORDER_ROUTER,
ESP_MATTER_MOUNTED_ON_OFF_CONTROL,
ESP_MATTER_MOUNTED_DIMMABLE_LOAD_CONTROL,
ESP_MATTER_WATER_HEATER,
ESP_MATTER_DEVICE_TYPE_MAX
};

Expand Down Expand Up @@ -116,5 +117,6 @@ const device_type_name device_type_list[ESP_MATTER_DEVICE_TYPE_MAX] = {
{"thread_border_router", ESP_MATTER_THREAD_BORDER_ROUTER},
{"mounted_on_off_control", ESP_MATTER_MOUNTED_ON_OFF_CONTROL},
{"mounted_dimmable_load_control", ESP_MATTER_MOUNTED_DIMMABLE_LOAD_CONTROL},
{"water_heater", ESP_MATTER_WATER_HEATER},
};
} /* namespace esp_matter */
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,11 @@ int create(uint8_t device_type_index)
endpoint = esp_matter::endpoint::mounted_dimmable_load_control::create(node, &mounted_dimmable_load_control_config, ENDPOINT_FLAG_NONE, NULL);
break;
}
case ESP_MATTER_WATER_HEATER: {
esp_matter::endpoint::water_heater::config_t water_heater_config;
endpoint = esp_matter::endpoint::water_heater::create(node, &water_heater_config, ENDPOINT_FLAG_NONE, NULL);
break;
}
default: {
ESP_LOGE(TAG, "Please input a valid device type");
break;
Expand Down

0 comments on commit af22b40

Please sign in to comment.