Skip to content

Commit

Permalink
Merge branch 'device/heat_pump' into 'main'
Browse files Browse the repository at this point in the history
components/esp-matter: Add Heat Pump device type.

See merge request app-frameworks/esp-matter!955
  • Loading branch information
dhrishi committed Dec 4, 2024
2 parents 4e2d150 + 8871204 commit fd02218
Show file tree
Hide file tree
Showing 5 changed files with 80 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 @@ -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
50 changes: 50 additions & 0 deletions components/esp_matter/esp_matter_endpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<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_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 {
Expand Down
22 changes: 22 additions & 0 deletions components/esp_matter/esp_matter_endpoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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<int64_t> voltage;
nullable<int64_t> 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 {
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 @@ -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
};

Expand Down Expand Up @@ -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 */
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit fd02218

Please sign in to comment.