Merge branch 'backport/1.5/commodity_clusters' into 'release/v1.5'

[v1.5]: commodity tariff, commodity price, commodity metering clusters

See merge request app-frameworks/esp-matter!1408
This commit is contained in:
Hrishikesh Dhayagude
2026-01-27 13:38:28 +08:00
15 changed files with 791 additions and 0 deletions
@@ -5088,5 +5088,183 @@ attribute_t *create_current_connections(cluster_t *cluster, uint8_t *value, uint
} /* push_av_stream_transport */
namespace commodity_tariff {
namespace attribute {
attribute_t *create_tariff_info(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
{
return esp_matter::attribute::create(cluster, CommodityTariff::Attributes::TariffInfo::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_array(value, length, count));
}
attribute_t *create_tariff_unit(cluster_t *cluster, nullable<uint8_t> value)
{
return esp_matter::attribute::create(cluster, CommodityTariff::Attributes::TariffUnit::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_enum8(value));
}
attribute_t *create_start_date(cluster_t *cluster, nullable<uint32_t> value)
{
return esp_matter::attribute::create(cluster, CommodityTariff::Attributes::StartDate::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value));
}
attribute_t *create_day_entries(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
{
return esp_matter::attribute::create(cluster, CommodityTariff::Attributes::DayEntries::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_array(value, length, count));
}
attribute_t *create_day_patterns(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
{
return esp_matter::attribute::create(cluster, CommodityTariff::Attributes::DayPatterns::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_array(value, length, count));
}
attribute_t *create_calendar_periods(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
{
return esp_matter::attribute::create(cluster, CommodityTariff::Attributes::CalendarPeriods::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_array(value, length, count));
}
attribute_t *create_individual_days(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
{
return esp_matter::attribute::create(cluster, CommodityTariff::Attributes::IndividualDays::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_array(value, length, count));
}
attribute_t *create_current_day(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
{
return esp_matter::attribute::create(cluster, CommodityTariff::Attributes::CurrentDay::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_array(value, length, count));
}
attribute_t *create_next_day(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
{
return esp_matter::attribute::create(cluster, CommodityTariff::Attributes::NextDay::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_array(value, length, count));
}
attribute_t *create_current_day_entry(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
{
return esp_matter::attribute::create(cluster, CommodityTariff::Attributes::CurrentDayEntry::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_array(value, length, count));
}
attribute_t *create_current_day_entry_date(cluster_t *cluster, nullable<uint32_t> value)
{
return esp_matter::attribute::create(cluster, CommodityTariff::Attributes::CurrentDayEntryDate::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value));
}
attribute_t *create_next_day_entry(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
{
return esp_matter::attribute::create(cluster, CommodityTariff::Attributes::NextDayEntry::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_array(value, length, count));
}
attribute_t *create_next_day_entry_date(cluster_t *cluster, nullable<uint32_t> value)
{
return esp_matter::attribute::create(cluster, CommodityTariff::Attributes::NextDayEntryDate::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value));
}
attribute_t *create_tariff_components(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
{
return esp_matter::attribute::create(cluster, CommodityTariff::Attributes::TariffComponents::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_array(value, length, count));
}
attribute_t *create_tariff_periods(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
{
return esp_matter::attribute::create(cluster, CommodityTariff::Attributes::TariffPeriods::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_array(value, length, count));
}
attribute_t *create_current_tariff_components(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
{
return esp_matter::attribute::create(cluster, CommodityTariff::Attributes::CurrentTariffComponents::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_array(value, length, count));
}
attribute_t *create_next_tariff_components(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
{
return esp_matter::attribute::create(cluster, CommodityTariff::Attributes::NextTariffComponents::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_array(value, length, count));
}
attribute_t *create_default_randomization_offset(cluster_t *cluster, nullable<int16_t> value)
{
return esp_matter::attribute::create(cluster, CommodityTariff::Attributes::DefaultRandomizationOffset::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_int16(value));
}
attribute_t *create_default_randomization_type(cluster_t *cluster, nullable<uint8_t> value)
{
return esp_matter::attribute::create(cluster, CommodityTariff::Attributes::DefaultRandomizationType::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_enum8(value));
}
} /* attribute */
} /* commodity_tariff */
namespace commodity_price {
namespace attribute {
attribute_t *create_tariff_unit(cluster_t *cluster, uint8_t value)
{
return esp_matter::attribute::create(cluster, CommodityPrice::Attributes::TariffUnit::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY, esp_matter_enum8(value));
}
attribute_t *create_currency(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
{
return esp_matter::attribute::create(cluster, CommodityPrice::Attributes::Currency::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_array(value, length, count));
}
attribute_t *create_current_price(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
{
return esp_matter::attribute::create(cluster, CommodityPrice::Attributes::CurrentPrice::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_array(value, length, count));
}
attribute_t *create_price_forecast(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
{
return esp_matter::attribute::create(cluster, CommodityPrice::Attributes::PriceForecast::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY, esp_matter_array(value, length, count));
}
} /* attribute */
} /* commodity_price */
namespace commodity_metering {
namespace attribute {
attribute_t *create_metered_quantity(cluster_t *cluster, uint8_t *value, uint16_t length, uint16_t count)
{
return esp_matter::attribute::create(cluster, CommodityMetering::Attributes::MeteredQuantity::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_array(value, length, count));
}
attribute_t *create_metered_quantity_timestamp(cluster_t *cluster, nullable<uint32_t> value)
{
return esp_matter::attribute::create(cluster, CommodityMetering::Attributes::MeteredQuantityTimestamp::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint32(value));
}
attribute_t *create_tariff_unit(cluster_t *cluster, nullable<uint8_t> value)
{
return esp_matter::attribute::create(cluster, CommodityMetering::Attributes::TariffUnit::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_enum8(value));
}
attribute_t *create_maximum_metered_quantities(cluster_t *cluster, nullable<uint16_t> value)
{
return esp_matter::attribute::create(cluster, CommodityMetering::Attributes::MaximumMeteredQuantities::Id,
ATTRIBUTE_FLAG_MANAGED_INTERNALLY | ATTRIBUTE_FLAG_NULLABLE, esp_matter_nullable_uint16(value));
}
} /* attribute */
} /* commodity_metering */
} /* cluster */
} /* esp_matter */
@@ -1324,5 +1324,48 @@ attribute_t *create_current_connections(cluster_t *cluster, uint8_t * value, uin
} /* attribute */
} /* push_av_stream_transport */
namespace commodity_tariff {
namespace attribute {
attribute_t *create_tariff_info(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
attribute_t *create_tariff_unit(cluster_t *cluster, nullable<uint8_t> value);
attribute_t *create_start_date(cluster_t *cluster, nullable<uint32_t> value);
attribute_t *create_day_entries(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
attribute_t *create_day_patterns(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
attribute_t *create_calendar_periods(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
attribute_t *create_individual_days(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
attribute_t *create_current_day(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
attribute_t *create_next_day(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
attribute_t *create_current_day_entry(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
attribute_t *create_current_day_entry_date(cluster_t *cluster, nullable<uint32_t> value);
attribute_t *create_next_day_entry(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
attribute_t *create_next_day_entry_date(cluster_t *cluster, nullable<uint32_t> value);
attribute_t *create_tariff_components(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
attribute_t *create_tariff_periods(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
attribute_t *create_current_tariff_components(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
attribute_t *create_next_tariff_components(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
attribute_t *create_default_randomization_offset(cluster_t *cluster, nullable<int16_t> value);
attribute_t *create_default_randomization_type(cluster_t *cluster, nullable<uint8_t> value);
} /* attribute */
} /* commodity_tariff */
namespace commodity_price {
namespace attribute {
attribute_t *create_tariff_unit(cluster_t *cluster, uint8_t value);
attribute_t *create_currency(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
attribute_t *create_current_price(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
attribute_t *create_price_forecast(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
} /* attribute */
} /* commodity_price */
namespace commodity_metering {
namespace attribute {
attribute_t *create_metered_quantity(cluster_t *cluster, uint8_t * value, uint16_t length, uint16_t count);
attribute_t *create_metered_quantity_timestamp(cluster_t *cluster, nullable<uint32_t> value);
attribute_t *create_tariff_unit(cluster_t *cluster, nullable<uint8_t> value);
attribute_t *create_maximum_metered_quantities(cluster_t *cluster, nullable<uint16_t> value);
} /* attribute */
} /* commodity_metering */
} /* cluster */
} /* esp_matter */
@@ -675,5 +675,80 @@ 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 */
@@ -49,5 +49,17 @@ void add_bounds_cb(cluster_t *cluster);
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 */
@@ -4336,5 +4336,156 @@ cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags)
} /* push_av_stream_transport */
namespace commodity_tariff {
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, CommodityTariff::Id, flags);
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, CommodityTariff::Id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = CommodityTariffDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
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));
/* Attributes managed internally */
global::attribute::create_feature_map(cluster, config->feature_flags);
attribute::create_tariff_info(cluster, NULL, 0, 0);
attribute::create_tariff_unit(cluster, 0);
attribute::create_start_date(cluster, 0);
attribute::create_day_entries(cluster, NULL, 0, 0);
attribute::create_day_patterns(cluster, NULL, 0, 0);
attribute::create_calendar_periods(cluster, NULL, 0, 0);
attribute::create_individual_days(cluster, NULL, 0, 0);
attribute::create_current_day(cluster, NULL, 0, 0);
attribute::create_next_day(cluster, NULL, 0, 0);
attribute::create_current_day_entry(cluster, NULL, 0, 0);
attribute::create_current_day_entry_date(cluster, 0);
attribute::create_next_day_entry(cluster, NULL, 0, 0);
attribute::create_next_day_entry_date(cluster, 0);
attribute::create_tariff_components(cluster, NULL, 0, 0);
attribute::create_tariff_periods(cluster, NULL, 0, 0);
attribute::create_current_tariff_components(cluster, NULL, 0, 0);
attribute::create_next_tariff_components(cluster, NULL, 0, 0);
/* Attributes not managed internally */
global::attribute::create_cluster_revision(cluster, cluster_revision);
// check against O.a+ feature conformance
VALIDATE_FEATURES_AT_LEAST_ONE("Pricing,FriendlyCredit,AuxiliaryLoad",
feature::pricing::get_id(), feature::friendly_credit::get_id(), feature::auxiliary_load::get_id());
if (has(feature::pricing::get_id())) {
VerifyOrReturnValue(feature::pricing::add(cluster) == ESP_OK, ABORT_CLUSTER_CREATE(cluster));
}
if (has(feature::friendly_credit::get_id())) {
VerifyOrReturnValue(feature::friendly_credit::add(cluster) == ESP_OK, ABORT_CLUSTER_CREATE(cluster));
}
if (has(feature::auxiliary_load::get_id())) {
VerifyOrReturnValue(feature::auxiliary_load::add(cluster) == ESP_OK, ABORT_CLUSTER_CREATE(cluster));
}
if (has(feature::power_threshold::get_id())) {
VerifyOrReturnValue(feature::power_threshold::add(cluster) == ESP_OK, ABORT_CLUSTER_CREATE(cluster));
}
if (has(feature::randomization::get_id())) {
VerifyOrReturnValue(feature::randomization::add(cluster) == ESP_OK, ABORT_CLUSTER_CREATE(cluster));
}
if (has(feature::peak_period::get_id())) {
VerifyOrReturnValue(feature::peak_period::add(cluster) == ESP_OK, ABORT_CLUSTER_CREATE(cluster));
}
command::create_get_tariff_component(cluster);
command::create_get_tariff_component_response(cluster);
command::create_get_day_entry(cluster);
command::create_get_day_entry_response(cluster);
}
if (flags & CLUSTER_FLAG_CLIENT) {
create_default_binding_cluster(endpoint);
}
return cluster;
}
} /* commodity_tariff */
namespace commodity_price {
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, CommodityPrice::Id, flags);
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, CommodityPrice::Id));
if (flags & CLUSTER_FLAG_SERVER) {
if (config && config->delegate != nullptr) {
static const auto delegate_init_cb = CommodityPriceDelegateInitCB;
set_delegate_and_init_callback(cluster, delegate_init_cb, config->delegate);
}
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 */
global::attribute::create_feature_map(cluster, 0);
attribute::create_tariff_unit(cluster, 0);
attribute::create_currency(cluster, NULL, 0, 0);
attribute::create_current_price(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;
}
} /* commodity_price */
namespace commodity_metering {
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, CommodityMetering::Id, flags);
VerifyOrReturnValue(cluster, NULL, ESP_LOGE(TAG, "Could not create cluster. cluster_id: 0x%08" PRIX32, CommodityMetering::Id));
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 */
global::attribute::create_feature_map(cluster, 0);
attribute::create_metered_quantity(cluster, NULL, 0, 0);
attribute::create_metered_quantity_timestamp(cluster, 0);
attribute::create_tariff_unit(cluster, 0);
attribute::create_maximum_metered_quantities(cluster, 1);
/* Attributes not managed internally */
global::attribute::create_cluster_revision(cluster, cluster_revision);
}
if (flags & CLUSTER_FLAG_CLIENT) {
create_default_binding_cluster(endpoint);
}
return cluster;
}
} /* commodity_metering */
} /* cluster */
} /* esp_matter */
@@ -1038,5 +1038,29 @@ typedef struct config {
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
} /* push_av_stream_transport */
namespace commodity_tariff {
typedef struct config {
void *delegate;
uint32_t feature_flags;
config() : delegate(nullptr), feature_flags(0) {}
} config_t;
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
} /* commodity_tariff */
namespace commodity_price {
typedef struct config {
void *delegate;
config() : delegate(nullptr) {}
} config_t;
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
} /* commodity_price */
namespace commodity_metering {
using config_t = common::config_t;
cluster_t *create(endpoint_t *endpoint, config_t *config, uint8_t flags);
} /* commodity_metering */
} /* cluster */
} /* esp_matter */
@@ -3146,5 +3146,63 @@ command_t *create_find_transport_response(cluster_t *cluster)
} /* command */
} /* push_av_stream_transport */
namespace commodity_tariff {
namespace command {
command_t *create_get_tariff_component(cluster_t *cluster)
{
return esp_matter::command::create(cluster, CommodityTariff::Commands::GetTariffComponent::Id,
COMMAND_FLAG_ACCEPTED, NULL);
}
command_t *create_get_tariff_component_response(cluster_t *cluster)
{
return esp_matter::command::create(cluster, CommodityTariff::Commands::GetTariffComponentResponse::Id,
COMMAND_FLAG_GENERATED, NULL);
}
command_t *create_get_day_entry(cluster_t *cluster)
{
return esp_matter::command::create(cluster, CommodityTariff::Commands::GetDayEntry::Id,
COMMAND_FLAG_ACCEPTED, NULL);
}
command_t *create_get_day_entry_response(cluster_t *cluster)
{
return esp_matter::command::create(cluster, CommodityTariff::Commands::GetDayEntryResponse::Id,
COMMAND_FLAG_GENERATED, NULL);
}
} /* command */
} /* commodity_tariff */
namespace commodity_price {
namespace command {
command_t *create_get_detailed_price_request(cluster_t *cluster)
{
return esp_matter::command::create(cluster, CommodityPrice::Commands::GetDetailedPriceRequest::Id,
COMMAND_FLAG_ACCEPTED, NULL);
}
command_t *create_get_detailed_price_response(cluster_t *cluster)
{
return esp_matter::command::create(cluster, CommodityPrice::Commands::GetDetailedPriceResponse::Id,
COMMAND_FLAG_GENERATED, NULL);
}
command_t *create_get_detailed_forecast_request(cluster_t *cluster)
{
return esp_matter::command::create(cluster, CommodityPrice::Commands::GetDetailedForecastRequest::Id,
COMMAND_FLAG_ACCEPTED, NULL);
}
command_t *create_get_detailed_forecast_response(cluster_t *cluster)
{
return esp_matter::command::create(cluster, CommodityPrice::Commands::GetDetailedForecastResponse::Id,
COMMAND_FLAG_GENERATED, NULL);
}
} /* command */
} /* commodity_price */
} /* cluster */
} /* esp_matter */
@@ -591,5 +591,23 @@ command_t *create_find_transport_response(cluster_t *cluster);
} /* command */
} /* push_av_stream_transport */
namespace commodity_tariff {
namespace command {
command_t *create_get_tariff_component(cluster_t *cluster);
command_t *create_get_tariff_component_response(cluster_t *cluster);
command_t *create_get_day_entry(cluster_t *cluster);
command_t *create_get_day_entry_response(cluster_t *cluster);
} /* command */
} /* commodity_tariff */
namespace commodity_price {
namespace command {
command_t *create_get_detailed_price_request(cluster_t *cluster);
command_t *create_get_detailed_price_response(cluster_t *cluster);
command_t *create_get_detailed_forecast_request(cluster_t *cluster);
command_t *create_get_detailed_forecast_response(cluster_t *cluster);
} /* command */
} /* commodity_price */
} /* cluster */
} /* esp_matter */
@@ -51,6 +51,8 @@
#include <app/clusters/closure-control-server/closure-control-server.h>
#include <app/clusters/closure-dimension-server/closure-dimension-server.h>
#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 <unordered_map>
using namespace chip::app::Clusters;
@@ -584,6 +586,26 @@ void PushAvStreamTransportDelegateInitCB(void *delegate, uint16_t endpoint_id)
pushavstreamtransportserverinstance->Init();
}
void CommodityTariffDelegateInitCB(void *delegate, uint16_t endpoint_id)
{
VerifyOrReturn(delegate != nullptr);
CommodityTariff::Delegate *commodity_tariff_delegate = static_cast<CommodityTariff::Delegate*>(delegate);
uint32_t feature_map = get_feature_map_value(endpoint_id, CommodityTariff::Id);
CommodityTariff::Instance *commodity_tariff_instance = new CommodityTariff::Instance(endpoint_id, *commodity_tariff_delegate, chip::BitMask<CommodityTariff::Feature, uint32_t>(feature_map));
commodity_tariff_instance->Init();
}
void CommodityPriceDelegateInitCB(void *delegate, uint16_t endpoint_id)
{
VerifyOrReturn(delegate != nullptr);
CommodityPrice::Delegate *commodity_price_delegate = static_cast<CommodityPrice::Delegate*>(delegate);
uint32_t feature_map = get_feature_map_value(endpoint_id, CommodityPrice::Id);
CommodityPrice::Instance *commodity_price_instance = new CommodityPrice::Instance(endpoint_id, *commodity_price_delegate, chip::BitMask<CommodityPrice::Feature, uint32_t>(feature_map));
commodity_price_instance->Init();
}
} // namespace delegate_cb
} // namespace cluster
} // namespace esp_matter
@@ -59,6 +59,8 @@ void ChimeDelegateInitCB(void *delegate, uint16_t endpoint_id);
void ClosureControlDelegateInitCB(void *delegate, uint16_t endpoint_id);
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);
} // namespace delegate_cb
} // namespace cluster
@@ -882,5 +882,15 @@ event_t *create_push_transport_end(cluster_t *cluster)
} // namespace event
} // namespace push_av_stream_transport
namespace commodity_price {
namespace event {
event_t *create_price_change(cluster_t *cluster)
{
return esp_matter::event::create(cluster, CommodityPrice::Events::PriceChange::Id);
}
} // namespace event
} // namespace commodity_price
} // namespace cluster
} // namespace esp_matter
@@ -279,5 +279,11 @@ event_t *create_push_transport_end(cluster_t *cluster);
} // namespace event
} // namespace push_av_stream_transport
namespace commodity_price {
namespace event {
event_t *create_price_change(cluster_t *cluster);
} // namespace event
} // namespace commodity_price
} // namespace cluster
} // namespace esp_matter
@@ -4537,5 +4537,132 @@ esp_err_t add(cluster_t *cluster)
} /* feature */
} /* push_av_stream_transport */
namespace commodity_tariff {
namespace feature {
namespace pricing {
uint32_t get_id()
{
return static_cast<uint32_t>(CommodityTariff::Feature::kPricing);
}
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());
return ESP_OK;
}
} /* pricing */
namespace friendly_credit {
uint32_t get_id()
{
return static_cast<uint32_t>(CommodityTariff::Feature::kFriendlyCredit);
}
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());
return ESP_OK;
}
} /* friendly_credit */
namespace auxiliary_load {
uint32_t get_id()
{
return static_cast<uint32_t>(CommodityTariff::Feature::kAuxiliaryLoad);
}
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());
return ESP_OK;
}
} /* auxiliary_load */
namespace peak_period {
uint32_t get_id()
{
return static_cast<uint32_t>(CommodityTariff::Feature::kPeakPeriod);
}
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());
return ESP_OK;
}
} /* peak_period */
namespace power_threshold {
uint32_t get_id()
{
return static_cast<uint32_t>(CommodityTariff::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());
return ESP_OK;
}
} /* power_threshold */
namespace randomization {
uint32_t get_id()
{
return static_cast<uint32_t>(CommodityTariff::Feature::kRandomization);
}
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_default_randomization_offset(cluster, 0);
attribute::create_default_randomization_type(cluster, 0);
return ESP_OK;
}
} /* randomization */
} /* feature */
} /* commodity_tariff */
namespace commodity_price {
namespace feature {
namespace forecasting {
uint32_t get_id()
{
return static_cast<uint32_t>(CommodityPrice::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_price_forecast(cluster, NULL, 0, 0);
return ESP_OK;
}
} /* forecasting */
} /* feature */
} /* commodity_price */
} /* cluster */
} /* esp_matter */
@@ -2031,5 +2031,59 @@ esp_err_t add(cluster_t *cluster);
} /* feature */
} /* push_av_stream_transport */
namespace commodity_tariff {
namespace feature {
namespace pricing {
uint32_t get_id();
esp_err_t add(cluster_t *cluster);
} /* pricing */
namespace friendly_credit {
uint32_t get_id();
esp_err_t add(cluster_t *cluster);
} /* friendly_credit */
namespace auxiliary_load {
uint32_t get_id();
esp_err_t add(cluster_t *cluster);
} /* auxiliary_load */
namespace peak_period {
uint32_t get_id();
esp_err_t add(cluster_t *cluster);
} /* peak_period */
namespace power_threshold {
uint32_t get_id();
esp_err_t add(cluster_t *cluster);
} /* power_threshold */
namespace randomization {
uint32_t get_id();
esp_err_t add(cluster_t *cluster);
} /* randomization */
} /* feature */
} /* commodity_tariff */
namespace commodity_price {
namespace feature {
namespace forecasting {
uint32_t get_id();
esp_err_t add(cluster_t *cluster);
} /* forecasting */
} /* feature */
} /* commodity_price */
} /* cluster */
} /* esp_matter */
@@ -399,6 +399,17 @@ namespace push_av_stream_transport {
constexpr uint16_t cluster_revision = 1;
} // namespace push_av_stream_transport
namespace commodity_tariff {
constexpr uint16_t cluster_revision = 1;
} // namespace commodity_tariff
namespace commodity_price {
constexpr uint16_t cluster_revision = 4;
} // namespace commodity_price
namespace commodity_metering {
constexpr uint16_t cluster_revision = 1;
} // namespace commodity_metering
} // namespace cluster
} // namespace esp_matter