[api] Fix comment source references and add missing max_data_length

- Fix comment: NAME_MAX_LENGTH is in config_validation.py, not core/config.py
- Add missing max_data_length=63 to unit_of_measurement in ListEntitiesNumberResponse
This commit is contained in:
J. Nick Koston
2026-04-05 19:07:22 -10:00
parent 2d43d07490
commit 4e99510624
2 changed files with 7 additions and 7 deletions
+6 -6
View File
@@ -308,11 +308,11 @@ enum EntityCategory {
ENTITY_CATEGORY_DIAGNOSTIC = 2;
}
// Entity field max_data_length values match constants in esphome/core/config.py:
// name/object_id = 120 (NAME_MAX_LENGTH)
// icon = 63 (ICON_MAX_LENGTH)
// device_class = 47 (DEVICE_CLASS_MAX_LENGTH)
// unit_of_measurement = 63 (UNIT_OF_MEASUREMENT_MAX_LENGTH)
// Entity field max_data_length values match Python validation constants:
// name/object_id = 120 (config_validation.NAME_MAX_LENGTH)
// icon = 63 (core/config.ICON_MAX_LENGTH)
// device_class = 47 (core/config.DEVICE_CLASS_MAX_LENGTH)
// unit_of_measurement = 63 (core/config.UNIT_OF_MEASUREMENT_MAX_LENGTH)
// ==================== BINARY SENSOR ====================
message ListEntitiesBinarySensorResponse {
@@ -1260,7 +1260,7 @@ message ListEntitiesNumberResponse {
float step = 8;
bool disabled_by_default = 9;
EntityCategory entity_category = 10;
string unit_of_measurement = 11;
string unit_of_measurement = 11 [(max_data_length) = 63];
NumberMode mode = 12;
string device_class = 13 [(max_data_length) = 47];
uint32 device_id = 14 [(field_ifdef) = "USE_DEVICES"];
+1 -1
View File
@@ -1705,7 +1705,7 @@ uint32_t ListEntitiesNumberResponse::calculate_size() const {
size += ProtoSize::calc_float(1, this->step);
size += ProtoSize::calc_bool(1, this->disabled_by_default);
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->entity_category));
size += ProtoSize::calc_length(1, this->unit_of_measurement.size());
size += !this->unit_of_measurement.empty() ? 2 + this->unit_of_measurement.size() : 0;
size += ProtoSize::calc_uint32(1, static_cast<uint32_t>(this->mode));
size += !this->device_class.empty() ? 2 + this->device_class.size() : 0;
#ifdef USE_DEVICES