Commit Graph

26868 Commits

Author SHA1 Message Date
J. Nick Koston d3df97f534 Merge remote-tracking branch 'origin/api-max-data-length-force' into integration 2026-04-06 18:42:13 -10:00
J. Nick Koston 9ed1a35544 Merge remote-tracking branch 'upstream/dev' into integration 2026-04-06 18:42:00 -10:00
J. Nick Koston b86ab07632 [core] Fix test for byte-length error message, add ByteLength and multibyte tests 2026-04-06 18:38:58 -10:00
J. Nick Koston cf9e79beda Merge branch 'dev' into api-max-data-length-force 2026-04-06 18:34:36 -10:00
J. Nick Koston cfcf9216f3 [core] Add cv.ByteLength validator, switch all proto-backed length checks to byte length
Add cv.ByteLength() validator that checks UTF-8 byte length instead
of character count. This ensures multibyte characters don't cause
the encoded string to exceed the proto max_data_length limit.

Switch all length validators that feed into proto fields with
max_data_length annotations to use byte length:
- Entity names, friendly names, area names, device names
- Icons, device classes, units of measurement
- Board names, project name/version
2026-04-06 18:33:04 -10:00
J. Nick Koston 52d76f8db0 [api] Fix name max_data_length to match hostname limit, add suggested_area
- Fix HelloResponse.name and DeviceInfoResponse.name max_data_length
  from 120 to 31 to match ESPHOME_DEVICE_NAME_MAX_LEN (hostname limit)
- Add max_data_length=120 + force to suggested_area field
- Add static_asserts for ESPHOME_DEVICE_NAME_MAX_LEN and
  ESPHOME_FRIENDLY_NAME_MAX_LEN
- Fix comments to accurately describe guarantees
2026-04-06 18:17:04 -10:00
J. Nick Koston 5a92a3b16e [api] Add max_data_length/force to model and project fields, validate board/project lengths
Add BOARD_MAX_LENGTH and PROJECT_MAX_LENGTH constants (127) and
enforce them in YAML validation for all platform board schemas
and project name/version.

Add max_data_length + force proto options to model, project_name,
and project_version fields in DeviceInfoResponse.
2026-04-06 18:14:18 -10:00
J. Nick Koston f94e1dfab6 [core] Move ControllerRegistry notify methods inline into header (#15505) 2026-04-07 16:12:01 +12:00
J. Nick Koston 95974358ab [api] Add max_data_length and force to DeviceInfoResponse/HelloResponse proto fields
Add max_data_length + force proto options to string fields in
HelloResponse, AreaInfo, DeviceInfo, and DeviceInfoResponse where
we have strong compile-time or codegen guarantees on max length.

This enables encode_short_string_force() (direct byte writes,
no varint branching) for fields with single-byte tags, and
fixed-formula size calculations for all annotated fields.

Add static_asserts to cross-validate C++ constexpr constants
(MAC_ADDRESS_PRETTY_BUFFER_SIZE, BUILD_TIME_STR_SIZE,
ESPHOME_VERSION, ESPHOME_MANUFACTURER) against the proto
max_data_length annotations.
2026-04-06 18:03:26 -10:00
Jonathan Swoboda e49384cd57 [dfrobot_sen0395] Fix list.index() on mutated list in range validator (#15511) 2026-04-06 23:42:39 -04:00
J. Nick Koston 14a48ec6ac Merge remote-tracking branch 'upstream/dev' into integration 2026-04-06 17:33:57 -10:00
J. Nick Koston 10b38e1588 [api] Add max_data_length proto option and optimize entity name/object_id (#15426) 2026-04-07 03:31:01 +00:00
J. Nick Koston e485011740 Merge remote-tracking branch 'upstream/dev' into integration 2026-04-06 17:29:12 -10:00
Jonathan Swoboda b6ef1a58fb [multiple] Fix validation ranges and error messages (#15508) 2026-04-06 23:17:35 -04:00
Jonathan Swoboda 9894bdc0f1 [multiple] Fix misc low-priority bugs (batch 3) (#15506) 2026-04-06 23:03:57 -04:00
J. Nick Koston 3f0b13deb3 Merge remote-tracking branch 'upstream/api-proto-max-length' into integration 2026-04-06 16:34:27 -10:00
J. Nick Koston 4461184afc Merge branch 'dev' into api-proto-max-length 2026-04-06 16:26:01 -10:00
J. Nick Koston 3c55828d81 Merge remote-tracking branch 'origin/controller-registry-inline-notify' into integration 2026-04-06 16:23:19 -10:00
J. Nick Koston e3e191b783 Merge remote-tracking branch 'upstream/dev' into integration 2026-04-06 16:23:07 -10:00
J. Nick Koston 5906421ab1 Merge branch 'dev' into controller-registry-inline-notify 2026-04-06 16:18:46 -10:00
Jonathan Swoboda 99ee405f4e [esp32_ble][esp32_ble_server][esp32_ble_beacon] Fix UUID regex, IndexError, and unused inheritance (#15504) 2026-04-06 22:17:34 -04:00
Jonathan Swoboda 517d0390d0 [ota] Fix check_error skipping validation for RESPONSE_OK (#15501) 2026-04-06 22:17:25 -04:00
J. Nick Koston ef29b18e18 [core] Move ControllerRegistry notify methods inline into header
Move the notify_*_update() method definitions from controller_registry.cpp
into controller_registry.h as inline functions. These are tiny loops over
1-2 controllers that each have a single call site in the entity's
notify_frontend_() method.

When defined in a separate TU, the compiler cannot inline them at the call
site without LTO, resulting in an unnecessary function-call frame on every
state publish. CodSpeed profiling of the CallbackManager container change
(#15272) showed this extra frame accounting for ~12% regression in text
sensor publish benchmarks.

controller_registry.h is only ever included from .cpp files (never from
other headers), so including controller.h after the class definition is
safe and introduces no circular dependencies.
2026-04-06 16:09:32 -10:00
J. Nick Koston 96c3986481 [core] Replace std::vector in CallbackManager with trivial-copy container (#15272) 2026-04-07 01:58:17 +00:00
Jonathan Swoboda e62c78ad46 [multiple] Fix misc cosmetic bugs (error messages, types, defaults) (#15499) 2026-04-07 01:41:57 +00:00
Jonathan Swoboda e428cb5092 [multiple] Fix misc cosmetic bugs (batch 2) (#15502) 2026-04-06 21:33:22 -04:00
Jonathan Swoboda b8b8d1bb15 [core] Replace deprecated datetime.utcfromtimestamp() (#15503) 2026-04-06 21:31:57 -04:00
J. Nick Koston 82dc80a413 [scheduler] Skip cancel for anonymous items, add empty-container fast path (#15397) 2026-04-07 01:26:40 +00:00
J. Nick Koston c1f8bdedc2 Merge remote-tracking branch 'upstream/dev' into api-proto-max-length
# Conflicts:
#	esphome/components/api/api_pb2.cpp
2026-04-06 14:48:45 -10:00
J. Nick Koston d15fa84f4f [api] Auto-derive max_value for enum fields in protobuf codegen (#15469) 2026-04-06 14:39:55 -10:00
Jonathan Swoboda 4fa3e48d33 [remote_base] Fix misc protocol schema and codegen bugs (#15497) 2026-04-07 00:34:07 +00:00
Jonathan Swoboda 094e0440c6 [config] Fix unfilled placeholder in dimensions() error message (#15498) 2026-04-06 14:30:36 -10:00
J. Nick Koston b155c13117 [api] Use integer comparison for float zero checks in protobuf encoding (#15490) 2026-04-07 12:25:53 +12:00
Jonathan Swoboda 0816579fa9 [prometheus] Fix relabel validation not checking for required keys (#15496) 2026-04-06 14:20:46 -10:00
Jonathan Swoboda c6e683cc33 [pmsx003] Connect model-specific sensor validation to schema (#15495) 2026-04-06 14:19:53 -10:00
Jonathan Swoboda 14bcd9db59 [neopixelbus] Fix SPI pin validation accepting one wrong pin on ESP8266 (#15494) 2026-04-06 14:18:59 -10:00
Jonathan Swoboda d9da91efbe [bl0940] Fix restore_value reading from wrong config dict (#15492) 2026-04-06 14:14:17 -10:00
J. Nick Koston 7293683297 Merge branch 'integration' of https://github.com/esphome/esphome into integration 2026-04-06 14:09:54 -10:00
J. Nick Koston 6523ed05b8 Merge branch 'float-to-raw-optimization-v2' into integration
# Conflicts:
#	esphome/components/api/proto.h
2026-04-06 14:08:50 -10:00
J. Nick Koston 136eabebb4 Merge branch 'api-enum-auto-max-value' into integration
# Conflicts:
#	esphome/components/api/api_pb2.cpp
#	script/api_protobuf/api_protobuf.py
2026-04-06 14:07:38 -10:00
Jesse Hills 017af24c22 Merge branch 'release' into dev 2026-04-07 12:06:30 +12:00
Jesse Hills 496c395f1a Merge pull request #15489 from esphome/bump-2026.3.3
2026.3.3
2026.3.3
2026-04-07 12:05:46 +12:00
J. Nick Koston 13e35db055 Restore IRAM_ATTR on wake_loop functions 2026-04-06 14:03:19 -10:00
J. Nick Koston 7c671cd0e6 Merge branch 'api-proto-max-length' into integration
# Conflicts:
#	esphome/components/api/api_connection.cpp
#	esphome/components/api/api_pb2.cpp
#	esphome/components/api/proto.h
#	esphome/core/application.h
#	esphome/core/component.cpp
#	script/api_protobuf/api_protobuf.py
2026-04-06 14:02:14 -10:00
J. Nick Koston 2eb3e25278 Add debug assert to encode_short_string_force for size < 128 2026-04-06 13:58:10 -10:00
Jonathan Swoboda 29ca7bc8f9 [espnow] Fix string data generating invalid C++ char literals (#15493) 2026-04-06 19:57:16 -04:00
J. Nick Koston be476c3a79 Merge remote-tracking branch 'upstream/api/peel-first-write-iteration' into integration 2026-04-06 13:49:16 -10:00
J. Nick Koston 17e5320836 do not force inline 2026-04-06 13:40:50 -10:00
J. Nick Koston 87622c9a74 [api] Add max_data_length proto option and optimize entity string encoding
Add a max_data_length field option to api_options.proto for string/bytes
fields. When max_data_length < 128 and force = true, the code generator
uses encode_short_string_force() — a single call that writes the tag
byte, 1-byte length varint, and raw string data with no branching. Size
calculation simplifies from calc_length(1, size) to 2 + size.

Annotate entity fields across all 25 ListEntities*Response messages:
- name and object_id: max_data_length = 120, force = true (50 fields)
- icon: max_data_length = 63 (25 fields)

The 120 and 63 values match NAME_MAX_LENGTH and ICON_MAX_LENGTH in
esphome/core/config.py, validated at config time.
2026-04-06 13:28:50 -10:00
J. Nick Koston 37258de6b1 [api] Auto-derive max_value for enum fields in protobuf codegen
Scan all enum definitions in api.proto at codegen time and automatically
populate max_value for enum-typed fields. This eliminates the need for
manual (max_value) annotations on every enum field.

When max_value < 128, the generated calculate_size uses constant-size
arithmetic instead of a function call:
- `calc_uint32(1, static_cast<uint32_t>(field))` → `field ? 2 : 0`

For repeated enum fields with constant element size, the per-element
loop is replaced with a multiply: `size += count * bytes_per_element`.
2026-04-06 13:19:37 -10:00