[web_server] Use centralized length constants for buffer sizing

This commit is contained in:
J. Nick Koston
2026-01-07 20:00:40 -10:00
parent 9a3d1f5acc
commit b8da3b3265
2 changed files with 4 additions and 2 deletions
+2 -1
View File
@@ -499,7 +499,8 @@ static void set_json_id(JsonObject &root, EntityBase *obj, const char *prefix, J
// Build id into stack buffer - ArduinoJson copies the string
// Format: {prefix}/{device?}/{name}
// Buffer sizes use constants from entity_base.h validated in core/config.py
// Note: Device name (USE_DEVICES) uses ESPHOME_FRIENDLY_NAME_MAX_LEN, not ESPHOME_DEVICE_NAME_MAX_LEN
// Note: Device name uses ESPHOME_FRIENDLY_NAME_MAX_LEN (sub-device max 120), not ESPHOME_DEVICE_NAME_MAX_LEN
// (hostname)
#ifdef USE_DEVICES
static constexpr size_t ID_BUF_SIZE =
ESPHOME_DOMAIN_MAX_LEN + 1 + ESPHOME_FRIENDLY_NAME_MAX_LEN + 1 + ESPHOME_FRIENDLY_NAME_MAX_LEN + 1;
+2 -1
View File
@@ -16,7 +16,8 @@ namespace esphome {
// Maximum device name length - keep in sync with validate_hostname() in esphome/core/config.py
static constexpr size_t ESPHOME_DEVICE_NAME_MAX_LEN = 31;
// Maximum friendly name length - keep in sync with friendly_name cv.Length(max=120) in esphome/core/config.py
// Maximum friendly name length for entities and sub-devices - keep in sync with cv.Length(max=120) in
// esphome/core/config.py
static constexpr size_t ESPHOME_FRIENDLY_NAME_MAX_LEN = 120;
// Maximum domain length (longest: "alarm_control_panel" = 19)