diff --git a/components/esp_matter/data_model/esp_matter_data_model.cpp b/components/esp_matter/data_model/esp_matter_data_model.cpp index 413c26eb8..c654c5a83 100644 --- a/components/esp_matter/data_model/esp_matter_data_model.cpp +++ b/components/esp_matter/data_model/esp_matter_data_model.cpp @@ -737,6 +737,18 @@ esp_err_t get_val(attribute_t *attribute, esp_matter_attr_val_t *val) return ESP_OK; } +esp_matter_val_type_t get_val_type(attribute_t *attribute) +{ + VerifyOrReturnValue(attribute, ESP_MATTER_VAL_TYPE_INVALID, ESP_LOGE(TAG, "Attribute cannot be NULL")); + _attribute_t *current_attribute = (_attribute_t *)attribute; + return current_attribute->attribute_val_type; +} + +esp_matter_val_type_t get_val_type(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id) +{ + return get_val_type(get(endpoint_id, cluster_id, attribute_id)); +} + esp_err_t add_bounds(attribute_t *attribute, esp_matter_attr_val_t min, esp_matter_attr_val_t max) { VerifyOrReturnError(attribute, ESP_ERR_INVALID_ARG, ESP_LOGE(TAG, "Attribute cannot be NULL")); diff --git a/components/esp_matter/data_model/esp_matter_data_model.h b/components/esp_matter/data_model/esp_matter_data_model.h index 22f24562b..8837c1b20 100644 --- a/components/esp_matter/data_model/esp_matter_data_model.h +++ b/components/esp_matter/data_model/esp_matter_data_model.h @@ -912,6 +912,26 @@ esp_err_t set_val(attribute_t *attribute, esp_matter_attr_val_t *val, bool call_ */ esp_err_t get_val(attribute_t *attribute, esp_matter_attr_val_t *val); +/** Get the attribute value type for the given attribute handle. + * + * @param[in] attribute Attribute handle. + * + * @return Attribute value type on success. + * @return ESP_MATTER_VAL_TYPE_INVALID, i.e. 0, in case of failure. + */ +esp_matter_val_type_t get_val_type(attribute_t *attribute); + +/** Get the attribute value type for the given endpoint, cluster and attribute id. + * + * @param[in] endpoint_id Endpoint id. + * @param[in] cluster_id Cluster id. + * @param[in] attribute_id Attribute id. + * + * @return Attribute value type on success. + * @return ESP_MATTER_VAL_TYPE_INVALID, i.e. 0, in case of failure. + */ +esp_matter_val_type_t get_val_type(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id); + /** Add attribute bounds * * Add bounds to the attribute (has `ATTRIBUTE_FLAG_EXTERNAL_STORAGE` flag). Bounds cannot be added to string/array type attributes.