diff --git a/components/esp_matter/esp_matter_attribute.cpp b/components/esp_matter/esp_matter_attribute.cpp index 4c520ebfc..ab4f68657 100644 --- a/components/esp_matter/esp_matter_attribute.cpp +++ b/components/esp_matter/esp_matter_attribute.cpp @@ -1898,5 +1898,125 @@ attribute_t *create_flow_tolerance(cluster_t *cluster, uint16_t value, uint16_t } /* attribute */ } /* flow_measurement */ +namespace pump_configuration_and_control { +namespace attribute { + +attribute_t *create_max_pressure(cluster_t *cluster, nullable value) +{ + return esp_matter::attribute::create(cluster, PumpConfigurationAndControl::Attributes::MaxPressure::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_int16(value)); +} + +attribute_t *create_max_speed(cluster_t *cluster, nullable value) +{ + return esp_matter::attribute::create(cluster, PumpConfigurationAndControl::Attributes::MaxSpeed::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint16(value)); +} + +attribute_t *create_max_flow(cluster_t *cluster, nullable value) +{ + return esp_matter::attribute::create(cluster, PumpConfigurationAndControl::Attributes::MaxFlow::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint16(value)); +} + +attribute_t *create_min_const_pressure(cluster_t *cluster, nullable value) +{ + return esp_matter::attribute::create(cluster, PumpConfigurationAndControl::Attributes::MinConstPressure::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_int16(value)); +} + +attribute_t *create_max_const_pressure(cluster_t *cluster, nullable value) +{ + return esp_matter::attribute::create(cluster, PumpConfigurationAndControl::Attributes::MaxConstPressure::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_int16(value)); +} + +attribute_t *create_min_comp_pressure(cluster_t *cluster, nullable value) +{ + return esp_matter::attribute::create(cluster, PumpConfigurationAndControl::Attributes::MinCompPressure::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_int16(value)); +} + +attribute_t *create_max_comp_pressure(cluster_t *cluster, nullable value) +{ + return esp_matter::attribute::create(cluster, PumpConfigurationAndControl::Attributes::MaxCompPressure::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_int16(value)); +} + +attribute_t *create_min_const_speed(cluster_t *cluster, nullable value) +{ + return esp_matter::attribute::create(cluster, PumpConfigurationAndControl::Attributes::MinConstSpeed::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint16(value)); +} + +attribute_t *create_max_const_speed(cluster_t *cluster, nullable value) +{ + return esp_matter::attribute::create(cluster, PumpConfigurationAndControl::Attributes::MaxConstSpeed::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint16(value)); +} + +attribute_t *create_min_const_flow(cluster_t *cluster, nullable value) +{ + return esp_matter::attribute::create(cluster, PumpConfigurationAndControl::Attributes::MinConstFlow::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint16(value)); +} + +attribute_t *create_max_const_flow(cluster_t *cluster, nullable value) +{ + return esp_matter::attribute::create(cluster, PumpConfigurationAndControl::Attributes::MaxConstFlow::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint16(value)); +} + +attribute_t *create_min_const_temp(cluster_t *cluster, nullable value) +{ + return esp_matter::attribute::create(cluster, PumpConfigurationAndControl::Attributes::MinConstTemp::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_int16(value)); +} + +attribute_t *create_max_const_temp(cluster_t *cluster, nullable value) +{ + return esp_matter::attribute::create(cluster, PumpConfigurationAndControl::Attributes::MaxConstTemp::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_int16(value)); +} + +attribute_t *create_pump_status(cluster_t *cluster, uint16_t value) +{ + return esp_matter::attribute::create(cluster, PumpConfigurationAndControl::Attributes::PumpStatus::Id, ATTRIBUTE_FLAG_NONE, esp_matter_bitmap16(value)); +} + +attribute_t *create_effective_operation_mode(cluster_t *cluster, uint8_t value) +{ + return esp_matter::attribute::create(cluster, PumpConfigurationAndControl::Attributes::EffectiveOperationMode::Id, ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_enum8(value)); +} + +attribute_t *create_effective_control_mode(cluster_t *cluster, uint8_t value) +{ + return esp_matter::attribute::create(cluster, PumpConfigurationAndControl::Attributes::EffectiveControlMode::Id, ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_enum8(value)); +} + +attribute_t *create_capacity(cluster_t *cluster, nullable value) +{ + return esp_matter::attribute::create(cluster, PumpConfigurationAndControl::Attributes::Capacity::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_int16(value)); +} + +attribute_t *create_speed(cluster_t *cluster, nullable value) +{ + return esp_matter::attribute::create(cluster, PumpConfigurationAndControl::Attributes::Speed::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint16(value)); +} + +attribute_t *create_lifetime_running_hours(cluster_t *cluster, nullable value) +{ + return esp_matter::attribute::create(cluster, PumpConfigurationAndControl::Attributes::LifetimeRunningHours::Id, ATTRIBUTE_FLAG_WRITABLE | ATTRIBUTE_FLAG_NULLABLE | ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_nullable_uint32(value)); +} + +attribute_t *create_pump_power(cluster_t *cluster, nullable value) +{ + return esp_matter::attribute::create(cluster, PumpConfigurationAndControl::Attributes::Power::Id, ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value)); +} + +attribute_t *create_lifetime_energy_consumed(cluster_t *cluster, nullable value) +{ + return esp_matter::attribute::create(cluster, PumpConfigurationAndControl::Attributes::LifetimeEnergyConsumed::Id, ATTRIBUTE_FLAG_WRITABLE | ATTRIBUTE_FLAG_NULLABLE | ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_nullable_uint32(value)); +} + +attribute_t *create_operation_mode(cluster_t *cluster, uint8_t value) +{ + return esp_matter::attribute::create(cluster, PumpConfigurationAndControl::Attributes::OperationMode::Id, ATTRIBUTE_FLAG_WRITABLE | ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_enum8(value)); +} + +attribute_t *create_control_mode(cluster_t *cluster, uint8_t value) +{ + return esp_matter::attribute::create(cluster, PumpConfigurationAndControl::Attributes::ControlMode::Id, ATTRIBUTE_FLAG_WRITABLE | ATTRIBUTE_FLAG_NONVOLATILE, esp_matter_enum8(value)); +} +} /* attribute */ +} /* pump_configuration_and_control */ + } /* cluster */ } /* esp_matter */ diff --git a/components/esp_matter/esp_matter_attribute.h b/components/esp_matter/esp_matter_attribute.h index 62b2e1d5a..3c5b4daa2 100644 --- a/components/esp_matter/esp_matter_attribute.h +++ b/components/esp_matter/esp_matter_attribute.h @@ -466,5 +466,33 @@ attribute_t *create_flow_tolerance(cluster_t *cluster, uint16_t value, uint16_t } /* attribute */ } /* flow_measurement */ +namespace pump_configuration_and_control { +namespace attribute { +attribute_t *create_max_pressure(cluster_t *cluster, nullable value); +attribute_t *create_max_speed(cluster_t *cluster, nullable value); +attribute_t *create_max_flow(cluster_t *cluster, nullable value); +attribute_t *create_min_const_pressure(cluster_t *cluster, nullable value); +attribute_t *create_max_const_pressure(cluster_t *cluster, nullable value); +attribute_t *create_min_comp_pressure(cluster_t *cluster, nullable value); +attribute_t *create_max_comp_pressure(cluster_t *cluster, nullable value); +attribute_t *create_min_const_speed(cluster_t *cluster, nullable value); +attribute_t *create_max_const_speed(cluster_t *cluster, nullable value); +attribute_t *create_min_const_flow(cluster_t *cluster, nullable value); +attribute_t *create_max_const_flow(cluster_t *cluster, nullable value); +attribute_t *create_min_const_temp(cluster_t *cluster, nullable value); +attribute_t *create_max_const_temp(cluster_t *cluster, nullable value); +attribute_t *create_pump_status(cluster_t *cluster, uint16_t value); +attribute_t *create_effective_operation_mode(cluster_t *cluster, uint8_t value); +attribute_t *create_effective_control_mode(cluster_t *cluster, uint8_t value); +attribute_t *create_capacity(cluster_t *cluster, nullable value); +attribute_t *create_speed(cluster_t *cluster, nullable value); +attribute_t *create_lifetime_running_hours(cluster_t *cluster, nullable value); +attribute_t *create_pump_power(cluster_t *cluster, nullable value); +attribute_t *create_lifetime_energy_consumed(cluster_t *cluster, nullable value); +attribute_t *create_operation_mode(cluster_t *cluster, uint8_t value); +attribute_t *create_control_mode(cluster_t *cluster, uint8_t value); +} /* attribute */ +} /* pump_configuration_and_control */ + } /* cluster */ } /* esp_matter */ diff --git a/components/esp_matter/esp_matter_cluster.cpp b/components/esp_matter/esp_matter_cluster.cpp index beee758c1..2b85876a7 100644 --- a/components/esp_matter/esp_matter_cluster.cpp +++ b/components/esp_matter/esp_matter_cluster.cpp @@ -1761,5 +1761,51 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) } } /* flow_measurement */ +namespace pump_configuration_and_control { +const function_generic_t function_list[] = { + (function_generic_t)emberAfPumpConfigurationAndControlClusterServerInitCallback, + (function_generic_t)MatterPumpConfigurationAndControlClusterServerPreAttributeChangedCallback, +}; +const int function_flags = CLUSTER_FLAG_INIT_FUNCTION | CLUSTER_FLAG_PRE_ATTRIBUTE_CHANGED_FUNCTION; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags) +{ + cluster_t *cluster = cluster::create(endpoint, PumpConfigurationAndControl::Id, flags); + if (!cluster) { + ESP_LOGE(TAG, "Could not create cluster"); + return NULL; + } + if (flags & CLUSTER_FLAG_SERVER) { + set_plugin_server_init_callback(cluster, MatterPumpConfigurationAndControlPluginServerInitCallback); + add_function_list(cluster, function_list, function_flags); + } + if (flags & CLUSTER_FLAG_CLIENT) { + set_plugin_client_init_callback(cluster, MatterPumpConfigurationAndControlPluginClientInitCallback); + create_default_binding_cluster(endpoint); + } + + if (flags & CLUSTER_FLAG_SERVER) { + /* Attributes managed internally */ + global::attribute::create_feature_map(cluster, 0); + + /** Attributes not managed internally **/ + if (config) { + global::attribute::create_cluster_revision(cluster, config->cluster_revision); + attribute::create_max_pressure(cluster, config->max_pressure); + attribute::create_max_speed(cluster, config->max_speed); + attribute::create_max_flow(cluster, config->max_flow); + attribute::create_effective_operation_mode(cluster, config->effective_operation_mode); + attribute::create_effective_control_mode(cluster, config->effective_control_mode); + attribute::create_capacity(cluster, config->capacity); + attribute::create_operation_mode(cluster, config->operation_mode); + } else { + ESP_LOGE(TAG, "Config is NULL. Cannot add some attributes."); + } + } + + return cluster; +} +} /* pump_configuration_and_control */ + } /* cluster */ } /* esp_matter */ diff --git a/components/esp_matter/esp_matter_cluster.h b/components/esp_matter/esp_matter_cluster.h index 87ba06a6f..d4d126076 100644 --- a/components/esp_matter/esp_matter_cluster.h +++ b/components/esp_matter/esp_matter_cluster.h @@ -448,7 +448,26 @@ typedef struct config { } config_t; cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); -} +} /* flow_measurement */ + +namespace pump_configuration_and_control { +typedef struct config { + uint16_t cluster_revision; + // Pump Information Attributes + const nullable max_pressure; + const nullable max_speed; + const nullable max_flow; + // Pump Dynamic Information Attributes + uint8_t effective_operation_mode; + uint8_t effective_control_mode; + nullable capacity; + // Pump Settings Attributes + uint8_t operation_mode; + config() : cluster_revision(3), max_pressure(), max_speed(), max_flow(), effective_operation_mode(0), effective_control_mode(0), capacity(), operation_mode(0) {} +} config_t; + +cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags); +} /* pump_configuration_and_control */ } /* cluster */ } /* esp_matter */ diff --git a/components/esp_matter/esp_matter_endpoint.cpp b/components/esp_matter/esp_matter_endpoint.cpp index 1dab3869f..f3de92856 100644 --- a/components/esp_matter/esp_matter_endpoint.cpp +++ b/components/esp_matter/esp_matter_endpoint.cpp @@ -840,6 +840,42 @@ endpoint_t *add(endpoint_t *endpoint, config_t *config) return endpoint; } } /* flow_sensor */ + +namespace pump{ + +uint32_t get_device_type_id() +{ + return ESP_MATTER_PUMP_DEVICE_TYPE_ID; +} + +uint8_t get_device_type_version() +{ + return ESP_MATTER_PUMP_DEVICE_TYPE_VERSION; +} + +endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_data) +{ + endpoint_t *endpoint = endpoint::create(node, flags, priv_data); + return add(endpoint, config); +} + +endpoint_t *add(endpoint_t *endpoint, config_t *config) +{ + if (!endpoint) { + ESP_LOGE(TAG, "Could not create endpoint"); + return NULL; + } + add_device_type(endpoint, get_device_type_id(), get_device_type_version()); + + identify::create(endpoint, &(config->identify), CLUSTER_FLAG_SERVER); + descriptor::create(endpoint, CLUSTER_FLAG_SERVER); + on_off::create(endpoint, &(config->on_off), CLUSTER_FLAG_SERVER, ESP_MATTER_NONE_FEATURE_ID); + pump_configuration_and_control::create(endpoint, &(config->pump_configuration_and_control), CLUSTER_FLAG_SERVER); + + return endpoint; +} +} /** pump **/ + } /* endpoint */ namespace node { diff --git a/components/esp_matter/esp_matter_endpoint.h b/components/esp_matter/esp_matter_endpoint.h index 33b39f268..7e3a79d5b 100644 --- a/components/esp_matter/esp_matter_endpoint.h +++ b/components/esp_matter/esp_matter_endpoint.h @@ -70,6 +70,8 @@ #define ESP_MATTER_DOOR_LOCK_DEVICE_TYPE_VERSION 2 #define ESP_MATTER_WINDOW_COVERING_DEVICE_TYPE_ID 0x0202 #define ESP_MATTER_WINDOW_COVERING_DEVICE_TYPE_VERSION 2 +#define ESP_MATTER_PUMP_DEVICE_TYPE_ID 0x0303 +#define ESP_MATTER_PUMP_DEVICE_TYPE_VERSION 2 namespace esp_matter { @@ -382,6 +384,19 @@ endpoint_t *create(node_t *node, config_t *config, uint8_t flags, void *priv_dat endpoint_t *add(endpoint_t *endpoint, config_t *config); } /* flow_sensor */ +namespace pump{ +typedef struct config { + cluster::identify::config_t identify; + cluster::on_off::config_t on_off; + cluster::pump_configuration_and_control::config_t pump_configuration_and_control; +} 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); +endpoint_t *add(endpoint_t *endpoint, config_t *config); +} /** pump **/ + } /* endpoint */ namespace node {