diff --git a/components/esp_matter/data_model/esp_matter_attribute.cpp b/components/esp_matter/data_model/esp_matter_attribute.cpp index d97e21f2d..8e9215f5c 100644 --- a/components/esp_matter/data_model/esp_matter_attribute.cpp +++ b/components/esp_matter/data_model/esp_matter_attribute.cpp @@ -5149,5 +5149,124 @@ 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 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 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 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 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 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 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 */ + } /* cluster */ } /* esp_matter */ diff --git a/components/esp_matter/data_model/esp_matter_attribute.h b/components/esp_matter/data_model/esp_matter_attribute.h index 3145b23b7..30afb7ba6 100644 --- a/components/esp_matter/data_model/esp_matter_attribute.h +++ b/components/esp_matter/data_model/esp_matter_attribute.h @@ -1333,5 +1333,29 @@ 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 value); +attribute_t *create_start_date(cluster_t *cluster, nullable 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 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 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 value); +attribute_t *create_default_randomization_type(cluster_t *cluster, nullable value); +} /* attribute */ +} /* commodity_tariff */ + } /* cluster */ } /* esp_matter */ diff --git a/components/esp_matter/data_model/esp_matter_attribute_bounds.cpp b/components/esp_matter/data_model/esp_matter_attribute_bounds.cpp index 6a064b696..254f3cc7f 100644 --- a/components/esp_matter/data_model/esp_matter_attribute_bounds.cpp +++ b/components/esp_matter/data_model/esp_matter_attribute_bounds.cpp @@ -714,5 +714,32 @@ 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 */ } /* cluster */ } /* esp_matter */ diff --git a/components/esp_matter/data_model/esp_matter_attribute_bounds.h b/components/esp_matter/data_model/esp_matter_attribute_bounds.h index 215b2b994..318f6453b 100644 --- a/components/esp_matter/data_model/esp_matter_attribute_bounds.h +++ b/components/esp_matter/data_model/esp_matter_attribute_bounds.h @@ -49,5 +49,9 @@ 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 */ } /* cluster */ } /* esp_matter */ diff --git a/components/esp_matter/data_model/esp_matter_cluster.cpp b/components/esp_matter/data_model/esp_matter_cluster.cpp index 63616caac..4fdd7ac47 100644 --- a/components/esp_matter/data_model/esp_matter_cluster.cpp +++ b/components/esp_matter/data_model/esp_matter_cluster.cpp @@ -4339,5 +4339,85 @@ 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 */ + } /* cluster */ } /* esp_matter */ diff --git a/components/esp_matter/data_model/esp_matter_cluster.h b/components/esp_matter/data_model/esp_matter_cluster.h index 601599758..04437e6ba 100644 --- a/components/esp_matter/data_model/esp_matter_cluster.h +++ b/components/esp_matter/data_model/esp_matter_cluster.h @@ -1038,5 +1038,15 @@ 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 */ + } /* cluster */ } /* esp_matter */ diff --git a/components/esp_matter/data_model/esp_matter_command.cpp b/components/esp_matter/data_model/esp_matter_command.cpp index 422948ffe..c28ac245f 100644 --- a/components/esp_matter/data_model/esp_matter_command.cpp +++ b/components/esp_matter/data_model/esp_matter_command.cpp @@ -3153,5 +3153,34 @@ 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 */ + } /* cluster */ } /* esp_matter */ diff --git a/components/esp_matter/data_model/esp_matter_command.h b/components/esp_matter/data_model/esp_matter_command.h index 5b8cf496a..58f31e4e3 100644 --- a/components/esp_matter/data_model/esp_matter_command.h +++ b/components/esp_matter/data_model/esp_matter_command.h @@ -592,5 +592,14 @@ 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 */ + } /* cluster */ } /* esp_matter */ diff --git a/components/esp_matter/data_model/esp_matter_delegate_callbacks.cpp b/components/esp_matter/data_model/esp_matter_delegate_callbacks.cpp index b6e39e108..7fb320a64 100644 --- a/components/esp_matter/data_model/esp_matter_delegate_callbacks.cpp +++ b/components/esp_matter/data_model/esp_matter_delegate_callbacks.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include using namespace chip::app::Clusters; @@ -584,6 +585,16 @@ 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(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(feature_map)); + commodity_tariff_instance->Init(); +} + } // namespace delegate_cb } // namespace cluster } // namespace esp_matter diff --git a/components/esp_matter/data_model/esp_matter_delegate_callbacks.h b/components/esp_matter/data_model/esp_matter_delegate_callbacks.h index b175ed800..1fa2effc2 100644 --- a/components/esp_matter/data_model/esp_matter_delegate_callbacks.h +++ b/components/esp_matter/data_model/esp_matter_delegate_callbacks.h @@ -59,6 +59,7 @@ 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); } // namespace delegate_cb } // namespace cluster diff --git a/components/esp_matter/data_model/esp_matter_feature.cpp b/components/esp_matter/data_model/esp_matter_feature.cpp index 52da8f685..8f21100c7 100644 --- a/components/esp_matter/data_model/esp_matter_feature.cpp +++ b/components/esp_matter/data_model/esp_matter_feature.cpp @@ -4674,5 +4674,109 @@ 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(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(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(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(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(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(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 */ + } /* cluster */ } /* esp_matter */ diff --git a/components/esp_matter/data_model/esp_matter_feature.h b/components/esp_matter/data_model/esp_matter_feature.h index 590a6bccc..b910364d0 100644 --- a/components/esp_matter/data_model/esp_matter_feature.h +++ b/components/esp_matter/data_model/esp_matter_feature.h @@ -2061,5 +2061,47 @@ 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 */ + } /* cluster */ } /* esp_matter */ diff --git a/components/esp_matter/data_model/private/esp_matter_cluster_revisions.h b/components/esp_matter/data_model/private/esp_matter_cluster_revisions.h index ede631f17..a29cba322 100644 --- a/components/esp_matter/data_model/private/esp_matter_cluster_revisions.h +++ b/components/esp_matter/data_model/private/esp_matter_cluster_revisions.h @@ -399,6 +399,9 @@ 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 cluster } // namespace esp_matter