diff --git a/SUPPORTED_DEVICE_TYPES.md b/SUPPORTED_DEVICE_TYPES.md index 7564cab58..2f9a7dcba 100644 --- a/SUPPORTED_DEVICE_TYPES.md +++ b/SUPPORTED_DEVICE_TYPES.md @@ -85,6 +85,7 @@ j. Energy 2. Water Heater 3. Solar Power 4. Battery Storage +5. Heat Pump k. Network Infrastructure 1. Thread Border Router diff --git a/components/esp_matter/esp_matter_endpoint.cpp b/components/esp_matter/esp_matter_endpoint.cpp index 38a95cc6f..0b651f84f 100644 --- a/components/esp_matter/esp_matter_endpoint.cpp +++ b/components/esp_matter/esp_matter_endpoint.cpp @@ -2156,6 +2156,56 @@ esp_err_t add(endpoint_t *endpoint, config_t *config) } } /* battery_storage */ +namespace heat_pump { +uint32_t get_device_type_id() +{ + return ESP_MATTER_HEAT_PUMP_DEVICE_TYPE_ID; +} + +uint8_t get_device_type_version() +{ + return ESP_MATTER_HEAT_PUMP_DEVICE_TYPE_VERSION; +} + +endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) +{ + return common::create(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_t *descriptor_cluster = cluster::get(endpoint, Descriptor::Id); + descriptor::feature::taglist::add(descriptor_cluster); + + power_source_device::add(endpoint, &config->power_source_device); + + cluster_t *power_source_cluster = cluster::get(endpoint, PowerSource::Id); + power_source::feature::wired::add(power_source_cluster, &config->power_source_device.power_source.wired); + + electrical_sensor::add(endpoint, &config->electrical_sensor); + + cluster_t *elec_power_measurement_cluster = cluster::get(endpoint, ElectricalPowerMeasurement::Id); + + electrical_power_measurement::attribute::create_voltage(elec_power_measurement_cluster, config->voltage); + electrical_power_measurement::attribute::create_active_current(elec_power_measurement_cluster, config->active_current); + + electrical_energy_measurement::create(endpoint, &(config->electrical_energy_measurement), CLUSTER_FLAG_SERVER, electrical_energy_measurement::feature::exported_energy::get_id() | electrical_energy_measurement::feature::cumulative_energy::get_id()); + + device_energy_management::add(endpoint, &config->device_energy_management); + + cluster_t *device_energy_management_cluster = cluster::get(endpoint, DeviceEnergyManagement::Id); + cluster::device_energy_management::feature::power_adjustment::add(device_energy_management_cluster); + return ESP_OK; +} +} /* heat_pump */ + } /* endpoint */ namespace node { diff --git a/components/esp_matter/esp_matter_endpoint.h b/components/esp_matter/esp_matter_endpoint.h index cec651ff9..ac3296670 100644 --- a/components/esp_matter/esp_matter_endpoint.h +++ b/components/esp_matter/esp_matter_endpoint.h @@ -145,6 +145,8 @@ #define ESP_MATTER_THREAD_BORDER_ROUTER_DEVICE_TYPE_ID 0x0091 #define ESP_MATTER_THREAD_BORDER_ROUTER_DEVICE_TYPE_VERSION 1 +#define ESP_MATTER_HEAT_PUMP_DEVICE_TYPE_ID 0x0309 +#define ESP_MATTER_HEAT_PUMP_DEVICE_TYPE_VERSION 1 namespace esp_matter { @@ -889,6 +891,26 @@ 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); } /** battery_storage **/ +namespace heat_pump { +typedef struct config { + cluster::descriptor::config_t descriptor; + power_source_device::config_t power_source_device; + electrical_sensor::config_t electrical_sensor; + device_energy_management::config_t device_energy_management; + cluster::electrical_energy_measurement::config_t electrical_energy_measurement; + + nullable voltage; + nullable active_current; + + config(): voltage(0), active_current(0) {} +} 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); +} /** heat_pump **/ + } /* endpoint */ namespace node { diff --git a/examples/all_device_types_app/main/device_types.h b/examples/all_device_types_app/main/device_types.h index 097e2e49f..c71009e1e 100644 --- a/examples/all_device_types_app/main/device_types.h +++ b/examples/all_device_types_app/main/device_types.h @@ -58,6 +58,7 @@ enum device_type_enum { ESP_MATTER_WATER_HEATER, ESP_MATTER_SOLAR_POWER, ESP_MATTER_BATTERY_STORAGE, + ESP_MATTER_HEAT_PUMP, ESP_MATTER_DEVICE_TYPE_MAX }; @@ -122,5 +123,6 @@ const device_type_name device_type_list[ESP_MATTER_DEVICE_TYPE_MAX] = { {"water_heater", ESP_MATTER_WATER_HEATER}, {"solar_power", ESP_MATTER_SOLAR_POWER}, {"battery_storage", ESP_MATTER_BATTERY_STORAGE}, + {"heat_pump", ESP_MATTER_HEAT_PUMP}, }; } /* namespace esp_matter */ diff --git a/examples/all_device_types_app/main/esp_matter_console_helpers.cpp b/examples/all_device_types_app/main/esp_matter_console_helpers.cpp index 901ed7a85..529c0854e 100644 --- a/examples/all_device_types_app/main/esp_matter_console_helpers.cpp +++ b/examples/all_device_types_app/main/esp_matter_console_helpers.cpp @@ -544,6 +544,11 @@ int create(uint8_t device_type_index) endpoint = esp_matter::endpoint::battery_storage::create(node, &battery_storage_config, ENDPOINT_FLAG_NONE, NULL); break; } + case ESP_MATTER_HEAT_PUMP: { + esp_matter::endpoint::heat_pump::config_t heat_pump_config; + endpoint = esp_matter::endpoint::heat_pump::create(node, &heat_pump_config, ENDPOINT_FLAG_NONE, NULL); + break; + } default: { ESP_LOGE(TAG, "Please input a valid device type"); break;