mirror of
https://github.com/espressif/esp-matter.git
synced 2026-04-27 11:03:05 +00:00
Merge branch 'backport/1.5/electrical_utility_clusters_and_devices' into 'release/v1.5'
[v1.5]: electrical grid condition, meter identification, electrical utility devices See merge request app-frameworks/esp-matter!1409
This commit is contained in:
@@ -10,9 +10,6 @@ set(INCLUDE_DIRS_LIST "."
|
||||
"${MATTER_SDK_PATH}/third_party/nlfaultinjection/include"
|
||||
"${MATTER_SDK_PATH}/src")
|
||||
|
||||
# TODO: These files have compilation errors
|
||||
set(EXCLUDE_SRCS_LIST "${MATTER_SDK_PATH}/src/app/clusters/commodity-tariff-server/commodity-tariff-server.cpp"
|
||||
"${MATTER_SDK_PATH}/src/app/clusters/commodity-tariff-server/CommodityTariffAttrsDataMgmt.cpp")
|
||||
set(PRIV_INCLUDE_DIRS_LIST )
|
||||
|
||||
if (CONFIG_ESP_MATTER_ENABLE_MATTER_SERVER)
|
||||
|
||||
@@ -5266,5 +5266,65 @@ attribute_t *create_maximum_metered_quantities(cluster_t *cluster, nullable<uint
|
||||
|
||||
} /* commodity_metering */
|
||||
|
||||
namespace electrical_grid_conditions {
|
||||
namespace attribute {
|
||||
attribute_t *create_local_generation_available(cluster_t *cluster, nullable<bool> value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, ElectricalGridConditions::Attributes::LocalGenerationAvailable::Id,
|
||||
ATTRIBUTE_FLAG_WRITABLE | ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_bool(value));
|
||||
}
|
||||
|
||||
attribute_t *create_current_conditions(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, ElectricalGridConditions::Attributes::CurrentConditions::Id,
|
||||
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_array(value, length, count));
|
||||
}
|
||||
|
||||
attribute_t *create_forecast_conditions(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, ElectricalGridConditions::Attributes::ForecastConditions::Id,
|
||||
ATTRIBUTE_FLAG_MANAGED_INTERNALLY, esp_matter_array(value, length, count));
|
||||
}
|
||||
|
||||
} /* attribute */
|
||||
|
||||
} /* electrical_grid_conditions */
|
||||
|
||||
namespace meter_identification {
|
||||
namespace attribute {
|
||||
attribute_t *create_meter_type(cluster_t *cluster, nullable<uint8_t> value)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, MeterIdentification::Attributes::MeterType::Id,
|
||||
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_enum8(value));
|
||||
}
|
||||
|
||||
attribute_t *create_point_of_delivery(cluster_t *cluster, char *value, uint16_t length)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, MeterIdentification::Attributes::PointOfDelivery::Id,
|
||||
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_char_str(value, length));
|
||||
}
|
||||
|
||||
attribute_t *create_meter_serial_number(cluster_t *cluster, char *value, uint16_t length)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, MeterIdentification::Attributes::MeterSerialNumber::Id,
|
||||
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_char_str(value, length));
|
||||
}
|
||||
|
||||
attribute_t *create_protocol_version(cluster_t *cluster, char *value, uint16_t length)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, MeterIdentification::Attributes::ProtocolVersion::Id,
|
||||
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_char_str(value, length));
|
||||
}
|
||||
|
||||
attribute_t *create_power_threshold(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
|
||||
{
|
||||
return esp_matter::attribute::create(cluster, MeterIdentification::Attributes::PowerThreshold::Id,
|
||||
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_array(value, length, count));
|
||||
}
|
||||
|
||||
} /* attribute */
|
||||
|
||||
} /* meter_identification */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -1367,5 +1367,25 @@ attribute_t *create_maximum_metered_quantities(cluster_t *cluster, nullable<uint
|
||||
} /* attribute */
|
||||
} /* commodity_metering */
|
||||
|
||||
namespace electrical_grid_conditions {
|
||||
namespace attribute {
|
||||
|
||||
attribute_t *create_local_generation_available(cluster_t *cluster, nullable<bool> value);
|
||||
attribute_t *create_current_conditions(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
|
||||
attribute_t *create_forecast_conditions(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
|
||||
} /* attribute */
|
||||
} /* electrical_grid_conditions */
|
||||
|
||||
namespace meter_identification {
|
||||
namespace attribute {
|
||||
|
||||
attribute_t *create_meter_type(cluster_t *cluster, nullable<uint8_t> value);
|
||||
attribute_t *create_point_of_delivery(cluster_t *cluster, char * value, uint16_t length);
|
||||
attribute_t *create_meter_serial_number(cluster_t *cluster, char * value, uint16_t length);
|
||||
attribute_t *create_protocol_version(cluster_t *cluster, char * value, uint16_t length);
|
||||
attribute_t *create_power_threshold(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
|
||||
} /* attribute */
|
||||
} /* meter_identification */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -676,79 +676,5 @@ void add_bounds_cb(cluster_t *cluster)
|
||||
}
|
||||
} /* camera_av_settings_user_level_management */
|
||||
|
||||
namespace commodity_tariff {
|
||||
|
||||
void add_bounds_cb(cluster_t *cluster)
|
||||
{
|
||||
VerifyOrReturn(cluster != nullptr, ESP_LOGE(TAG, "Cluster is NULL. Add bounds Failed!!"));
|
||||
attribute_t *current_attribute = esp_matter::attribute::get_first(cluster);
|
||||
VerifyOrReturn(current_attribute != nullptr, ESP_LOGE(TAG, "Attribute is NULL."));
|
||||
while(current_attribute) {
|
||||
switch(esp_matter::attribute::get_id(current_attribute)) {
|
||||
case CommodityTariff::Attributes::TariffUnit::Id: {
|
||||
uint8_t min = 0, max = 1;
|
||||
esp_matter::attribute::add_bounds(current_attribute, esp_matter_enum8(min), esp_matter_enum8(max));
|
||||
break;
|
||||
}
|
||||
case CommodityTariff::Attributes::DefaultRandomizationType::Id: {
|
||||
uint8_t min = 0, max = 4;
|
||||
esp_matter::attribute::add_bounds(current_attribute, esp_matter_enum8(min), esp_matter_enum8(max));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
current_attribute = esp_matter::attribute::get_next(current_attribute);
|
||||
}
|
||||
}
|
||||
} /* commodity_tariff */
|
||||
|
||||
namespace commodity_price {
|
||||
void add_bounds_cb(cluster_t *cluster)
|
||||
{
|
||||
VerifyOrReturn(cluster != nullptr, ESP_LOGE(TAG, "Cluster is NULL. Add bounds Failed!!"));
|
||||
attribute_t *current_attribute = esp_matter::attribute::get_first(cluster);
|
||||
VerifyOrReturn(current_attribute != nullptr, ESP_LOGE(TAG, "Attribute is NULL."));
|
||||
while(current_attribute) {
|
||||
switch(esp_matter::attribute::get_id(current_attribute)) {
|
||||
case CommodityPrice::Attributes::TariffUnit::Id: {
|
||||
uint8_t min = 0, max = 1;
|
||||
esp_matter::attribute::add_bounds(current_attribute, esp_matter_enum8(min), esp_matter_enum8(max));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
current_attribute = esp_matter::attribute::get_next(current_attribute);
|
||||
}
|
||||
}
|
||||
} /* commodity_price */
|
||||
|
||||
namespace commodity_metering {
|
||||
|
||||
void add_bounds_cb(cluster_t *cluster)
|
||||
{
|
||||
VerifyOrReturn(cluster != nullptr, ESP_LOGE(TAG, "Cluster is NULL. Add bounds Failed!!"));
|
||||
attribute_t *current_attribute = esp_matter::attribute::get_first(cluster);
|
||||
VerifyOrReturn(current_attribute != nullptr, ESP_LOGE(TAG, "Attribute is NULL."));
|
||||
while(current_attribute) {
|
||||
switch(esp_matter::attribute::get_id(current_attribute)) {
|
||||
case CommodityMetering::Attributes::MaximumMeteredQuantities::Id: {
|
||||
uint16_t min = 1, max = UINT16_MAX;
|
||||
esp_matter::attribute::add_bounds(current_attribute, esp_matter_uint16(min), esp_matter_uint16(max));
|
||||
break;
|
||||
}
|
||||
case CommodityMetering::Attributes::TariffUnit::Id: {
|
||||
uint8_t min = 0, max = 1;
|
||||
esp_matter::attribute::add_bounds(current_attribute, esp_matter_enum8(min), esp_matter_enum8(max));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
current_attribute = esp_matter::attribute::get_next(current_attribute);
|
||||
}
|
||||
}
|
||||
} /* commodity_metering */
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -50,16 +50,5 @@ namespace camera_av_settings_user_level_management {
|
||||
void add_bounds_cb(cluster_t *cluster);
|
||||
} /* camera_av_settings_user_level_management */
|
||||
|
||||
namespace commodity_tariff {
|
||||
void add_bounds_cb(cluster_t *cluster);
|
||||
} /* commodity_tariff */
|
||||
|
||||
namespace commodity_price {
|
||||
void add_bounds_cb(cluster_t *cluster);
|
||||
} /* commodity_price */
|
||||
|
||||
namespace commodity_metering {
|
||||
void add_bounds_cb(cluster_t *cluster);
|
||||
} /* commodity_metering */
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -4352,7 +4352,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
|
||||
}
|
||||
static const auto plugin_server_init_cb = CALL_ONCE(MatterCommodityTariffPluginServerInitCallback);
|
||||
set_plugin_server_init_callback(cluster, plugin_server_init_cb);
|
||||
set_add_bounds_callback(cluster, commodity_tariff::add_bounds_cb);
|
||||
add_function_list(cluster, function_list, function_flags);
|
||||
|
||||
VerifyOrReturnValue(config != NULL, ABORT_CLUSTER_CREATE(cluster));
|
||||
@@ -4432,7 +4431,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
|
||||
}
|
||||
static const auto plugin_server_init_cb = CALL_ONCE(MatterCommodityPricePluginServerInitCallback);
|
||||
set_plugin_server_init_callback(cluster, plugin_server_init_cb);
|
||||
set_add_bounds_callback(cluster, commodity_price::add_bounds_cb);
|
||||
add_function_list(cluster, function_list, function_flags);
|
||||
|
||||
/* Attributes managed internally */
|
||||
@@ -4465,7 +4463,6 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
|
||||
if (flags & CLUSTER_FLAG_SERVER) {
|
||||
static const auto plugin_server_init_cb = CALL_ONCE(MatterCommodityMeteringPluginServerInitCallback);
|
||||
set_plugin_server_init_callback(cluster, plugin_server_init_cb);
|
||||
set_add_bounds_callback(cluster, commodity_metering::add_bounds_cb);
|
||||
add_function_list(cluster, function_list, function_flags);
|
||||
|
||||
/* Attributes managed internally */
|
||||
@@ -4487,5 +4484,72 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
|
||||
|
||||
} /* commodity_metering */
|
||||
|
||||
namespace electrical_grid_conditions {
|
||||
const function_generic_t *function_list = NULL;
|
||||
|
||||
const int function_flags = CLUSTER_FLAG_NONE;
|
||||
|
||||
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
|
||||
{
|
||||
cluster_t *cluster = esp_matter::cluster::create(endpoint, ElectricalGridConditions::Id, flags);
|
||||
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, ElectricalGridConditions::Id));
|
||||
if (flags & CLUSTER_FLAG_SERVER) {
|
||||
if (config && config->delegate != nullptr) {
|
||||
static const auto delegate_init_cb = ElectricalGridConditionsDelegateInitCB;
|
||||
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
|
||||
}
|
||||
static const auto plugin_server_init_cb = CALL_ONCE(MatterElectricalGridConditionsPluginServerInitCallback);
|
||||
set_plugin_server_init_callback(cluster, plugin_server_init_cb);
|
||||
add_function_list(cluster, function_list, function_flags);
|
||||
|
||||
/* Attributes managed internally */
|
||||
global::attribute::create_feature_map(cluster, 0);
|
||||
attribute::create_local_generation_available(cluster, false);
|
||||
attribute::create_current_conditions(cluster, NULL, 0, 0);
|
||||
|
||||
/* Attributes not managed internally */
|
||||
global::attribute::create_cluster_revision(cluster, cluster_revision);
|
||||
}
|
||||
|
||||
if (flags & CLUSTER_FLAG_CLIENT) {
|
||||
create_default_binding_cluster(endpoint);
|
||||
}
|
||||
return cluster;
|
||||
}
|
||||
|
||||
} /* electrical_grid_conditions */
|
||||
|
||||
namespace meter_identification {
|
||||
const function_generic_t *function_list = NULL;
|
||||
|
||||
const int function_flags = CLUSTER_FLAG_NONE;
|
||||
|
||||
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
|
||||
{
|
||||
cluster_t *cluster = esp_matter::cluster::create(endpoint, MeterIdentification::Id, flags);
|
||||
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, MeterIdentification::Id));
|
||||
if (flags & CLUSTER_FLAG_SERVER) {
|
||||
static const auto plugin_server_init_cb = CALL_ONCE(MatterMeterIdentificationPluginServerInitCallback);
|
||||
set_plugin_server_init_callback(cluster, plugin_server_init_cb);
|
||||
add_function_list(cluster, function_list, function_flags);
|
||||
|
||||
/* Attributes managed internally */
|
||||
global::attribute::create_feature_map(cluster, 0);
|
||||
attribute::create_meter_type(cluster, 0);
|
||||
attribute::create_point_of_delivery(cluster, NULL, 0);
|
||||
attribute::create_meter_serial_number(cluster, NULL, 0);
|
||||
|
||||
/* Attributes not managed internally */
|
||||
global::attribute::create_cluster_revision(cluster, cluster_revision);
|
||||
}
|
||||
|
||||
if (flags & CLUSTER_FLAG_CLIENT) {
|
||||
create_default_binding_cluster(endpoint);
|
||||
}
|
||||
return cluster;
|
||||
}
|
||||
|
||||
} /* meter_identification */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -1062,5 +1062,20 @@ using config_t = common::config_t;
|
||||
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
|
||||
} /* commodity_metering */
|
||||
|
||||
namespace electrical_grid_conditions {
|
||||
typedef struct config {
|
||||
void *delegate;
|
||||
config() : delegate(nullptr) {}
|
||||
} config_t;
|
||||
|
||||
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
|
||||
} /* electrical_grid_conditions */
|
||||
|
||||
namespace meter_identification {
|
||||
using config_t = common::config_t;
|
||||
|
||||
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
|
||||
} /* meter_identification */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#include <app/clusters/push-av-stream-transport-server/push-av-stream-transport-cluster.h>
|
||||
#include <app/clusters/commodity-tariff-server/commodity-tariff-server.h>
|
||||
#include <app/clusters/commodity-price-server/commodity-price-server.h>
|
||||
#include <app/clusters/electrical-grid-conditions-server/electrical-grid-conditions-server.h>
|
||||
#include <unordered_map>
|
||||
|
||||
using namespace chip::app::Clusters;
|
||||
@@ -606,6 +607,16 @@ void CommodityPriceDelegateInitCB(void *delegate, uint16_t endpoint_id)
|
||||
commodity_price_instance->Init();
|
||||
}
|
||||
|
||||
|
||||
void ElectricalGridConditionsDelegateInitCB(void *delegate, uint16_t endpoint_id)
|
||||
{
|
||||
VerifyOrReturn(delegate != nullptr);
|
||||
ElectricalGridConditions::Delegate *electrical_grid_conditions_delegate = static_cast<ElectricalGridConditions::Delegate*>(delegate);
|
||||
uint32_t feature_map = get_feature_map_value(endpoint_id, ElectricalGridConditions::Id);
|
||||
ElectricalGridConditions::Instance *electrical_grid_conditions_instance = new ElectricalGridConditions::Instance(endpoint_id, *electrical_grid_conditions_delegate, chip::BitMask<ElectricalGridConditions::Feature, uint32_t>(feature_map));
|
||||
electrical_grid_conditions_instance->Init();
|
||||
}
|
||||
|
||||
} // namespace delegate_cb
|
||||
} // namespace cluster
|
||||
} // namespace esp_matter
|
||||
|
||||
@@ -61,6 +61,7 @@ void ClosureDimensionDelegateInitCB(void *delegate, uint16_t endpoint_id);
|
||||
void PushAvStreamTransportDelegateInitCB(void *delegate, uint16_t endpoint_id);
|
||||
void CommodityTariffDelegateInitCB(void *delegate, uint16_t endpoint_id);
|
||||
void CommodityPriceDelegateInitCB(void *delegate, uint16_t endpoint_id);
|
||||
void ElectricalGridConditionsDelegateInitCB(void *delegate, uint16_t endpoint_id);
|
||||
} // namespace delegate_cb
|
||||
|
||||
} // namespace cluster
|
||||
|
||||
@@ -2199,6 +2199,81 @@ esp_err_t add(endpoint_t *endpoint, config_t *config)
|
||||
return ESP_OK;
|
||||
}
|
||||
} /* closure_panel */
|
||||
|
||||
namespace electrical_utility_meter {
|
||||
uint32_t get_device_type_id()
|
||||
{
|
||||
return ESP_MATTER_ELECTRICAL_UTILITY_METER_DEVICE_TYPE_ID;
|
||||
}
|
||||
|
||||
uint8_t get_device_type_version()
|
||||
{
|
||||
return ESP_MATTER_ELECTRICAL_UTILITY_METER_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)
|
||||
{
|
||||
esp_err_t err = add_device_type(endpoint, get_device_type_id(), get_device_type_version());
|
||||
VerifyOrReturnError(err == ESP_OK, err);
|
||||
cluster::meter_identification::create(endpoint, &(config->meter_identification), CLUSTER_FLAG_SERVER);
|
||||
return ESP_OK;
|
||||
}
|
||||
} /* electrical_utility_meter */
|
||||
|
||||
namespace electrical_energy_tariff {
|
||||
uint32_t get_device_type_id()
|
||||
{
|
||||
return ESP_MATTER_ELECTRICAL_ENERGY_TARIFF_DEVICE_TYPE_ID;
|
||||
}
|
||||
|
||||
uint8_t get_device_type_version()
|
||||
{
|
||||
return ESP_MATTER_ELECTRICAL_ENERGY_TARIFF_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)
|
||||
{
|
||||
esp_err_t err = add_device_type(endpoint, get_device_type_id(), get_device_type_version());
|
||||
VerifyOrReturnError(err == ESP_OK, err);
|
||||
return ESP_OK;
|
||||
}
|
||||
} /* electrical_energy_tariff */
|
||||
|
||||
namespace electrical_meter {
|
||||
uint32_t get_device_type_id()
|
||||
{
|
||||
return ESP_MATTER_ELECTRICAL_METER_DEVICE_TYPE_ID;
|
||||
}
|
||||
|
||||
uint8_t get_device_type_version()
|
||||
{
|
||||
return ESP_MATTER_ELECTRICAL_METER_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)
|
||||
{
|
||||
esp_err_t err = add_device_type(endpoint, get_device_type_id(), get_device_type_version());
|
||||
VerifyOrReturnError(err == ESP_OK, err);
|
||||
cluster::electrical_power_measurement::create(endpoint, &(config->electrical_power_measurement), CLUSTER_FLAG_SERVER);
|
||||
cluster::electrical_energy_measurement::create(endpoint, &(config->electrical_energy_measurement), CLUSTER_FLAG_SERVER);
|
||||
return ESP_OK;
|
||||
}
|
||||
} /* electrical_meter */
|
||||
} /* endpoint */
|
||||
|
||||
namespace node {
|
||||
|
||||
@@ -161,7 +161,12 @@
|
||||
#define ESP_MATTER_CLOSURE_PANEL_DEVICE_TYPE_VERSION 1
|
||||
#define ESP_MATTER_CHIME_DEVICE_TYPE_ID 0x0146
|
||||
#define ESP_MATTER_CHIME_DEVICE_TYPE_VERSION 1
|
||||
|
||||
#define ESP_MATTER_ELECTRICAL_UTILITY_METER_DEVICE_TYPE_ID 0x0511
|
||||
#define ESP_MATTER_ELECTRICAL_UTILITY_METER_DEVICE_TYPE_VERSION 1
|
||||
#define ESP_MATTER_ELECTRICAL_ENERGY_TARIFF_DEVICE_TYPE_ID 0x0513
|
||||
#define ESP_MATTER_ELECTRICAL_ENERGY_TARIFF_DEVICE_TYPE_VERSION 1
|
||||
#define ESP_MATTER_ELECTRICAL_METER_DEVICE_TYPE_ID 0x0514
|
||||
#define ESP_MATTER_ELECTRICAL_METER_DEVICE_TYPE_VERSION 1
|
||||
namespace esp_matter {
|
||||
|
||||
/** Specific endpoint (device type) create APIs
|
||||
@@ -1108,6 +1113,42 @@ 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);
|
||||
} /* closure_panel */
|
||||
|
||||
namespace electrical_utility_meter {
|
||||
typedef struct config {
|
||||
cluster::descriptor::config_t descriptor;
|
||||
cluster::meter_identification::config_t meter_identification;
|
||||
} 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);
|
||||
} /* electrical_utility_meter */
|
||||
|
||||
namespace electrical_energy_tariff {
|
||||
typedef struct config {
|
||||
cluster::descriptor::config_t descriptor;
|
||||
} 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);
|
||||
} /* electrical_energy_tariff */
|
||||
|
||||
namespace electrical_meter {
|
||||
typedef struct config {
|
||||
cluster::descriptor::config_t descriptor;
|
||||
cluster::electrical_power_measurement::config_t electrical_power_measurement;
|
||||
cluster::electrical_energy_measurement::config_t electrical_energy_measurement;
|
||||
} 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);
|
||||
} /* electrical_meter */
|
||||
} /* endpoint */
|
||||
|
||||
namespace node {
|
||||
|
||||
@@ -892,5 +892,15 @@ event_t *create_price_change(cluster_t *cluster)
|
||||
} // namespace event
|
||||
} // namespace commodity_price
|
||||
|
||||
namespace electrical_grid_conditions {
|
||||
namespace event {
|
||||
event_t *create_current_conditions_changed(cluster_t *cluster)
|
||||
{
|
||||
return esp_matter::event::create(cluster, ElectricalGridConditions::Events::CurrentConditionsChanged::Id);
|
||||
}
|
||||
|
||||
} // namespace event
|
||||
} // namespace electrical_grid_conditions
|
||||
|
||||
} // namespace cluster
|
||||
} // namespace esp_matter
|
||||
|
||||
@@ -285,5 +285,11 @@ event_t *create_price_change(cluster_t *cluster);
|
||||
} // namespace event
|
||||
} // namespace commodity_price
|
||||
|
||||
namespace electrical_grid_conditions {
|
||||
namespace event {
|
||||
event_t *create_current_conditions_changed(cluster_t *cluster);
|
||||
} // namespace event
|
||||
} // namespace electrical_grid_conditions
|
||||
|
||||
} // namespace cluster
|
||||
} // namespace esp_matter
|
||||
|
||||
@@ -4664,5 +4664,51 @@ esp_err_t add(cluster_t *cluster)
|
||||
} /* feature */
|
||||
} /* commodity_price */
|
||||
|
||||
namespace electrical_grid_conditions {
|
||||
namespace feature {
|
||||
namespace forecasting {
|
||||
|
||||
uint32_t get_id()
|
||||
{
|
||||
return static_cast<uint32_t>(ElectricalGridConditions::Feature::kForecasting);
|
||||
}
|
||||
|
||||
esp_err_t add(cluster_t *cluster)
|
||||
{
|
||||
VerifyOrReturnError(cluster, ESP_ERR_INVALID_ARG, ESP_LOGE(TAG, "Cluster cannot be NULL"));
|
||||
update_feature_map(cluster, get_id());
|
||||
// Attributes
|
||||
attribute::create_forecast_conditions(cluster, NULL, 0, 0);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
} /* forecasting */
|
||||
|
||||
} /* feature */
|
||||
} /* electrical_grid_conditions */
|
||||
|
||||
namespace meter_identification {
|
||||
namespace feature {
|
||||
namespace power_threshold {
|
||||
|
||||
uint32_t get_id()
|
||||
{
|
||||
return static_cast<uint32_t>(MeterIdentification::Feature::kPowerThreshold);
|
||||
}
|
||||
|
||||
esp_err_t add(cluster_t *cluster)
|
||||
{
|
||||
VerifyOrReturnError(cluster, ESP_ERR_INVALID_ARG, ESP_LOGE(TAG, "Cluster cannot be NULL"));
|
||||
update_feature_map(cluster, get_id());
|
||||
// Attributes
|
||||
attribute::create_power_threshold(cluster, NULL, 0, 0);
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
} /* power_threshold */
|
||||
|
||||
} /* feature */
|
||||
} /* meter_identification */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -2085,5 +2085,29 @@ esp_err_t add(cluster_t *cluster);
|
||||
} /* feature */
|
||||
} /* commodity_price */
|
||||
|
||||
namespace electrical_grid_conditions {
|
||||
namespace feature {
|
||||
|
||||
namespace forecasting {
|
||||
|
||||
uint32_t get_id();
|
||||
esp_err_t add(cluster_t *cluster);
|
||||
} /* forecasting */
|
||||
|
||||
} /* feature */
|
||||
} /* electrical_grid_conditions */
|
||||
|
||||
namespace meter_identification {
|
||||
namespace feature {
|
||||
|
||||
namespace power_threshold {
|
||||
|
||||
uint32_t get_id();
|
||||
esp_err_t add(cluster_t *cluster);
|
||||
} /* power_threshold */
|
||||
|
||||
} /* feature */
|
||||
} /* meter_identification */
|
||||
|
||||
} /* cluster */
|
||||
} /* esp_matter */
|
||||
|
||||
@@ -410,6 +410,14 @@ constexpr uint16_t cluster_revision = 4;
|
||||
namespace commodity_metering {
|
||||
constexpr uint16_t cluster_revision = 1;
|
||||
} // namespace commodity_metering
|
||||
|
||||
namespace electrical_grid_conditions {
|
||||
constexpr uint16_t cluster_revision = 1;
|
||||
} // namespace electrical_grid_conditions
|
||||
|
||||
namespace meter_identification {
|
||||
constexpr uint16_t cluster_revision = 1;
|
||||
} // namespace meter_identification
|
||||
} // namespace cluster
|
||||
} // namespace esp_matter
|
||||
|
||||
|
||||
@@ -67,6 +67,8 @@ void MatterElectricalPowerMeasurementPluginServerInitCallback() {}
|
||||
void MatterServiceAreaPluginServerInitCallback() {}
|
||||
void MatterWaterHeaterManagementPluginServerInitCallback() {}
|
||||
void MatterWaterHeaterModePluginServerInitCallback() {}
|
||||
void MatterCommodityTariffPluginServerInitCallback() {}
|
||||
void MatterCommodityPricePluginServerInitCallback() {}
|
||||
void MatterCommodityMeteringPluginServerInitCallback() {}
|
||||
void MatterElectricalGridConditionsPluginServerInitCallback() {}
|
||||
void MatterSoilMeasurementPluginServerInitCallback() {}
|
||||
|
||||
@@ -64,6 +64,9 @@ enum device_type_enum {
|
||||
ESP_MATTER_CLOSURE_CONTROLLER,
|
||||
ESP_MATTER_CLOSURE,
|
||||
ESP_MATTER_CLOSURE_PANEL,
|
||||
ESP_MATTER_ELECTRICAL_ENERGY_TARIFF,
|
||||
ESP_MATTER_ELECTRICAL_METER,
|
||||
ESP_MATTER_ELECTRICAL_UTILITY_METER,
|
||||
ESP_MATTER_DEVICE_TYPE_MAX
|
||||
};
|
||||
|
||||
@@ -134,5 +137,8 @@ const device_type_name device_type_list[ESP_MATTER_DEVICE_TYPE_MAX] = {
|
||||
{"closure_controller", ESP_MATTER_CLOSURE_CONTROLLER},
|
||||
{"closure", ESP_MATTER_CLOSURE},
|
||||
{"closure_panel", ESP_MATTER_CLOSURE_PANEL},
|
||||
{"electrical_energy_tariff", ESP_MATTER_ELECTRICAL_ENERGY_TARIFF},
|
||||
{"electrical_meter", ESP_MATTER_ELECTRICAL_METER},
|
||||
{"electrical_utility_meter", ESP_MATTER_ELECTRICAL_UTILITY_METER},
|
||||
};
|
||||
} /* namespace esp_matter */
|
||||
|
||||
@@ -613,6 +613,34 @@ int create(uint8_t device_type_index)
|
||||
endpoint = esp_matter::endpoint::closure_panel::create(node, &closure_panel_config, ENDPOINT_FLAG_NONE, NULL);
|
||||
break;
|
||||
}
|
||||
case ESP_MATTER_ELECTRICAL_ENERGY_TARIFF: {
|
||||
esp_matter::endpoint::electrical_energy_tariff::config_t electrical_energy_tariff_config;
|
||||
endpoint = esp_matter::endpoint::electrical_energy_tariff::create(node, &electrical_energy_tariff_config, ENDPOINT_FLAG_NONE, NULL);
|
||||
|
||||
cluster::commodity_price::config_t commodity_price_config;
|
||||
cluster::commodity_price::create(endpoint, &commodity_price_config, CLUSTER_FLAG_SERVER);
|
||||
|
||||
cluster::commodity_tariff::config_t commodity_tariff_config;
|
||||
commodity_tariff_config.feature_flags = cluster::commodity_tariff::feature::pricing::get_id();
|
||||
cluster::commodity_tariff::create(endpoint, &commodity_tariff_config, CLUSTER_FLAG_SERVER);
|
||||
|
||||
break;
|
||||
}
|
||||
case ESP_MATTER_ELECTRICAL_METER: {
|
||||
esp_matter::endpoint::electrical_meter::config_t electrical_meter_config;
|
||||
electrical_meter_config.electrical_power_measurement.feature_flags = cluster::electrical_power_measurement::feature::direct_current::get_id();
|
||||
electrical_meter_config.electrical_energy_measurement.feature_flags = cluster::electrical_energy_measurement::feature::imported_energy::get_id() |
|
||||
cluster::electrical_energy_measurement::feature::exported_energy::get_id() |
|
||||
cluster::electrical_energy_measurement::feature::cumulative_energy::get_id() |
|
||||
cluster::electrical_energy_measurement::feature::periodic_energy::get_id();
|
||||
endpoint = esp_matter::endpoint::electrical_meter::create(node, &electrical_meter_config, ENDPOINT_FLAG_NONE, NULL);
|
||||
break;
|
||||
}
|
||||
case ESP_MATTER_ELECTRICAL_UTILITY_METER: {
|
||||
esp_matter::endpoint::electrical_utility_meter::config_t electrical_utility_meter_config;
|
||||
endpoint = esp_matter::endpoint::electrical_utility_meter::create(node, &electrical_utility_meter_config, ENDPOINT_FLAG_NONE, NULL);
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
ESP_LOGE(TAG, "Please input a valid device type");
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user