mirror of
https://github.com/esphome/esphome.git
synced 2026-09-13 16:18:41 +00:00
[web_server] Use centralized length constants for buffer sizing
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user