Commit Graph
25652 Commits
Author SHA1 Message Date
J. Nick Koston f744568689 Merge remote-tracking branch 'upstream/component-8byte-optimization' into integration 2026-03-22 21:40:00 -10:00
J. Nick Koston bd7bdc0e2d Merge remote-tracking branch 'upstream/devirtualize-decode' into integration 2026-03-22 21:39:51 -10:00
J. Nick Koston 010d7699f2 Use walrus operator in _generate_component_source_table 2026-03-22 21:30:42 -10:00
J. Nick Koston 099bea00f6 Add test for _generate_source_table_code empty input 2026-03-22 21:30:22 -10:00
J. Nick Koston ebb11206e3 Fix stale comment on component_source_index_ field 2026-03-22 21:25:24 -10:00
J. Nick Koston a92281f899 Add tests for register_component_source, remove redundant index check
- Test empty name returns 0
- Test deduplication returns same index
- Test overflow warns and returns 0
- Remove duplicate index==0 check in get_component_log_str() since
  component_source_lookup() already handles it
2026-03-22 21:24:13 -10:00
J. Nick Koston d755922aae Merge remote-tracking branch 'upstream/dev' into devirtualize-decode 2026-03-22 21:18:09 -10:00
J. Nick Koston f059a1c2ea [api] Remove USE_API guards from api_pb2_service (aligned with parent PR) 2026-03-22 21:18:04 -10:00
J. Nick Koston 0ec2a288a3 Merge branch 'dev' into component-8byte-optimization 2026-03-22 21:16:55 -10:00
J. Nick Koston 33bb87b813 Simplify to uint8_t index, add friend declarations, fix tests
- Drop 9-bit index scheme in favor of plain uint8_t (max 255 unique
  source names, overflow warns in Python and returns 0)
- Add friend declarations for setup()/original_setup() so generated
  code can call protected set_component_source_()
- Move get_component_log_str() out of line
- Fix test mocks to provide CORE.data dict
2026-03-22 21:16:18 -10:00
J. Nick Koston 5560c9eef7 [test] Fix flakey ld2412 integration test race condition (#15100) 2026-03-22 21:10:51 -10:00
J. Nick Koston f4097d5a95 [api] Devirtualize API command dispatch (#15044) 2026-03-23 19:57:40 +13:00
Keith BurzinskiandClaude Sonnet 4.6 225330413a [uart] Rename FlushResult to UARTFlushResult with UART_FLUSH_RESULT_ prefix (#15101)
Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-23 01:55:14 -05:00
J. Nick Koston e67b5a78d0 [esp32] Patch DRAM segment for testing mode to fix grouped component test overflow (#15102) 2026-03-23 01:51:40 -05:00
J. Nick Koston a6b9dd321d [core] Shrink Component from 12 to 8 bytes per instance
Replace 4-byte component_source_ pointer with a 9-bit index into a
PROGMEM lookup table generated by Python codegen. Source names are
deduplicated at codegen time (same pattern as EntityStringPool).

Shrink warn_if_blocking_over_ from uint16_t (ms) to uint8_t
(centiseconds), saturating at 255 (2550ms).

Saves 4 bytes per component instance (typical configs: 120-200 bytes).
2026-03-22 19:55:34 -10:00
J. Nick Koston 9ad332457e Merge branch 'deprecate-sensor-raw-state' into integration 2026-03-22 19:19:53 -10:00
J. Nick Koston 5519c2a5a3 [sensor] Narrow pragma to just the raw_state access line, matching select pattern 2026-03-22 19:19:09 -10:00
J. Nick Koston a1b1df3f71 Merge remote-tracking branch 'upstream/deprecate-sensor-raw-state' into integration 2026-03-22 19:10:28 -10:00
J. Nick Koston cab07c537e [sensor] Narrow pragma scope to only functions accessing deprecated raw_state
Scope the deprecation warning suppression to just the constructor
and publish_state() instead of the entire file, so unrelated
deprecation warnings aren't accidentally hidden.
2026-03-22 18:56:15 -10:00
J. Nick Koston 5e8497d611 Merge remote-tracking branch 'origin/fix-roaming-counter-reset' into integration 2026-03-22 18:52:39 -10:00
J. Nick Koston 3e8125799f Merge branch 'binary-sensor-remove-optional-state' into integration 2026-03-22 18:50:20 -10:00
J. Nick Koston 5be49b947a Merge remote-tracking branch 'origin/text-sensor-guard-raw-callback' into integration 2026-03-22 18:47:25 -10:00
J. Nick Koston 39782ff3f7 Merge branch 'dev' into text-sensor-guard-raw-callback 2026-03-22 18:47:09 -10:00
J. Nick Koston 801b16f3fd Merge remote-tracking branch 'upstream/dev' into integration 2026-03-22 18:46:46 -10:00
J. Nick Koston eaf38c10cc [binary_sensor] Use const T* instead of T current{} in set_new_state
Avoids requiring T to be default-constructible, which would break
future instantiations with non-default-constructible state types.

Capture old_state before set_state_value() since the pointer aliases
subclass storage that gets overwritten.
2026-03-22 18:40:00 -10:00
J. Nick Koston cd5b19ab0d [binary_sensor] Fast-path dedup in send_state_internal before virtual dispatch
Check state == new_state directly before calling virtual set_new_state.
Avoids the virtual dispatch chain (BinarySensor::set_new_state →
StatefulEntityBase::set_new_state → virtual get_state()) on the
common no-change path. Fixes -20% CodSpeed regression on
BinarySensorPublish_NoChange benchmark.
2026-03-22 18:38:34 -10:00
J. Nick Koston 84c58403f7 [sensor] Clarify compile-time vs runtime in raw_callback comment 2026-03-22 18:34:28 -10:00
J. Nick Koston 936764b89a [text_sensor] Clarify compile-time vs runtime in raw_callback comment 2026-03-22 18:33:58 -10:00
J. Nick Koston 99c0db34cc Merge branch 'dev' into deprecate-sensor-raw-state 2026-03-22 18:26:43 -10:00
J. Nick Koston baf365404c [network] Inline get_use_address() to eliminate function call overhead (#14942) 2026-03-23 04:18:43 +00:00
J. Nick Koston 4a200f8a2b [binary_sensor] Reduce flash: cache get_state(), guard full_state_callbacks call
- Cache get_state() result to avoid calling the virtual method twice
  (once for comparison, once for old_state construction)
- Move full_state_callbacks_.call() inside the !empty() guard so both
  the optional construction and the call are skipped when no callbacks
- Swap to had_state || get_trigger_on_initial_state() so the virtual
  call is skipped on the common path (every change except the first)

Saves ~21 bytes of flash in set_new_state.
2026-03-22 18:16:57 -10:00
J. Nick Koston 8a4b152488 Merge branch 'dev' into binary-sensor-remove-optional-state 2026-03-22 18:08:32 -10:00
J. Nick Koston 874b30d97d [wifi] Fix roaming attempt counter reset on disconnect during scan
When WiFi disconnects while a roaming scan is in progress, the
SCANNING state was transitioning to IDLE in retry_connect(). When the
device then reconnected, check_connecting_finished() treated the IDLE
state as a normal connection and reset roaming_attempts_ to 0. This
caused the roaming counter to perpetually restart at 1/3 instead of
progressing to 2/3, 3/3, creating an infinite loop of roaming scans
every 5 minutes.

This is most likely to occur on ESP8266 where disconnect callbacks
run immediately in SDK system context (setting error_from_callback_
before the main loop can process scan results), compared to ESP32 IDF
where events are queued and the scan-done event is typically processed
before the disconnect.

Fix by transitioning to RECONNECTING instead of IDLE when a disconnect
occurs during SCANNING. This preserves the attempts counter on
successful reconnection, allowing the device to reach the 3-attempt
limit and stop scanning.
2026-03-22 18:04:58 -10:00
J. Nick Koston 1458b03d7f Merge branch 'dev' into text-sensor-guard-raw-callback 2026-03-22 18:03:12 -10:00
J. Nick Koston efcb660691 [text_sensor] Guard raw_callback_ behind USE_TEXT_SENSOR_FILTER
Same pattern as sensor: raw_callback_ is only needed when filters are
configured. add_on_raw_state_callback remains always available —
without filters it delegates to callback_ since raw == filtered.

Saves 4 bytes per TextSensor instance on builds without filters.
2026-03-22 17:48:12 -10:00
J. Nick Koston 0de2c758aa [scheduler] Use placement-new for std::function move in set_timer_common_ (#14757) 2026-03-23 16:31:27 +13:00
J. Nick Koston 597bb18543 [benchmark] Add binary sensor publish and sensor filter benchmarks (#15035) 2026-03-23 16:30:57 +13:00
Jesse Hills ebdf20adc0 Merge branch 'release' into dev 2026-03-23 16:10:17 +13:00
J. Nick Koston 0b66dc7a34 Merge branch 'dev' into deprecate-sensor-raw-state 2026-03-22 17:10:06 -10:00
J. Nick Koston 5e3d1f8de2 Merge branch 'dev' into binary-sensor-remove-optional-state 2026-03-22 17:09:40 -10:00
Jesse Hills 7ecdf6db2e Merge pull request #15084 from esphome/bump-2026.3.1
2026.3.1
2026.3.1
2026-03-23 16:09:32 +13:00
J. Nick Koston 8a3b5a8def [core] Fix placement new storage name for templated types (#15096) 2026-03-23 16:09:23 +13:00
J. Nick Koston 65f02ac690 Merge remote-tracking branch 'upstream/fix-pstorage-template-namespace' into binary-sensor-remove-optional-state 2026-03-22 16:59:09 -10:00
J. Nick Koston 6c95f2e706 [core] Fix placement new storage name for templated types
When Pvariable types contain template arguments with :: (e.g.
Automation<std::optional<bool>>), the namespace extraction logic
incorrectly split on :: inside the template params, producing
invalid C++ identifiers like Automation<std__automation_id__pstorage.

Fix by stripping template arguments before extracting the namespace.
Extract the logic into a testable _extract_component_ns helper.
2026-03-22 16:56:35 -10:00
J. Nick Koston 9578376f46 [sensor] Remove USE_SENSOR_FILTER guard from SensorRawStateTrigger
add_on_raw_state_callback is always available now (delegates to
callback_ without filters). SensorRawStateTrigger doesn't need
the guard, and on_raw_value doesn't need to set USE_SENSOR_FILTER.

Without filters raw == filtered, so the trigger fires with the
correct value either way — no wasted RAM on filter infrastructure.
2026-03-22 16:51:01 -10:00
J. Nick Koston 30b5c3fb71 [sensor] Keep add_on_raw_state_callback always available
Delegate to callback_ when USE_SENSOR_FILTER is off since raw state
equals filtered state without filters. This avoids requiring external
components to know about USE_SENSOR_FILTER.
2026-03-22 16:49:20 -10:00
J. Nick Koston 9291b71176 [binary_sensor] Move set_trigger_on_initial_state off StatefulEntityBase
set_trigger_on_initial_state is only called from codegen on concrete
BinarySensor instances. It's an implementation detail of BinarySensor,
not part of the StatefulEntityBase contract. Only get_trigger_on_initial_state
remains as a pure virtual — subclasses decide how to control it.
2026-03-22 16:45:00 -10:00
J. Nick Koston 8aa9a82c13 [binary_sensor] Clarify trigger_on_initial_state docs - subclass decides storage 2026-03-22 16:43:37 -10:00
J. Nick Koston a6e230d665 [binary_sensor] Restore comment about USE_BINARY_SENSOR guard 2026-03-22 16:40:47 -10:00
J. Nick Koston 1a8cbe92ff [binary_sensor] Update StatefulEntityBase docs to reflect virtual dispatch design 2026-03-22 16:39:28 -10:00