Commit Graph
13706 Commits
Author SHA1 Message Date
J. Nick Koston 33e646cedf [core] Store parent pointer as member to enable inline Callback storage
Callback::create() can store callables inline (no heap allocation)
when they fit in sizeof(void*) — i.e., a single [this] capture on
32-bit platforms. Many automation triggers captured [this, parent]
in their callback lambdas, doubling the capture size and forcing
heap allocation.

Store the parent/state pointer as a class member and capture only
[this] in the lambda. This trades 4 bytes of member storage for
avoiding a permanent heap allocation per callback registration.

Components changed: cover, valve, lock, fan, media_player, datetime,
display_menu_base, graphical_display_menu, esp32_improv, mqtt_fan.
2026-03-18 09:05:18 -10:00
J. Nick Koston 8b931b7ac0 Merge branch 'dev' into lightweight-callback-manager 2026-03-16 08:09:16 -10:00
J. Nick Koston 2bdf1d0e42 [core] Add std::launder, fix static_assert comment, document call()
- Add std::launder to reinterpret_cast in inline callback path for
  formal C++20 correctness (generates identical code)
- Fix static_assert comment: sizeof equality ensures round-trip through
  uintptr_t, not absence of trap representations per se
- Document that call() is only valid on Callbacks from create()
2026-03-16 08:07:03 -10:00
J. Nick KostonandClaude Opus 4.6 db405c483e [core] Cache errno to avoid duplicate __errno() calls (#14751)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16 07:35:34 -10:00
J. Nick KostonandClaude Opus 4.6 808c7b67b3 [core] Inline WarnIfComponentBlockingGuard::finish() into header (#14798)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-16 07:35:19 -10:00
J. Nick Koston 7131eafc09 [logger] Reduce per-message overhead by inlining hot path helpers (#14851) 2026-03-16 07:35:04 -10:00
J. Nick KostonandCopilot Autofix powered by AI 7b4af76a61 [core] Inline Mutex on all embedded platforms (#14756)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-03-16 07:33:10 -10:00
J. Nick Koston 2cd93daa5e [api] Optimize plaintext varint encoding and devirtualize write_protobuf_packet (#14758) 2026-03-16 07:32:58 -10:00
J. Nick KostonandCopilot Autofix powered by AI f86bb2bdb0 [ethernet] Add IDF 6.0 registry component dependencies (#14847)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
2026-03-16 08:02:59 -04:00
J. Nick Koston 29882cf036 [core] Rename Callback fields to fn_ and ctx_ for consistency 2026-03-15 23:10:13 -10:00
J. Nick Koston 7edcc15cee [core] Address review nits
- Remove stale #include <functional> from microphone headers
- Add default initializers to Callback::fn and Callback::ctx
- Remove redundant cb.ctx = nullptr (now default-initialized)
2026-03-15 23:08:48 -10:00
J. Nick Koston 610258b683 [core] Convert remaining callback registration methods to templates
Convert rotary_encoder register_listener, canbus add_callback,
sdl add_key_listener, and udp add_listener from std::function to
templates to avoid the heap-allocation fallback path.

MQTT backend set_on_* methods are virtual and cannot be templatized.
2026-03-15 23:04:47 -10:00
J. Nick Koston 073dd3995e [microphone] Remove unnecessary std::function wrapping in callbacks
Pass wrapping lambdas directly to CallbackManager::add() instead of
first wrapping in std::function. The lambdas capture [this, callback]
(two pointers) so they hit the heap path either way, but this avoids
double-wrapping and the extra std::function overhead.

Also fix "deallaction" typo.
2026-03-15 22:59:19 -10:00
J. Nick Koston 1357de1fcd [microphone] Remove empty microphone.cpp
The only function was inlined into the header as a template.
2026-03-15 22:53:59 -10:00
J. Nick Koston fd51f0603e [core] Convert remaining add_*_callback methods to templates
Convert haier, nextion, microphone, ezo, uart, speaker, zigbee,
and hlk_fm22x callback methods that were missed by the initial
conversion (they used add_*_callback instead of add_on_*_callback).
2026-03-15 22:48:58 -10:00
J. Nick Koston 30e6e0a6b7 [core] Add static_assert for void* / uintptr_t size parity
Ensures the inline Callback storage path is only used on platforms
where void* has no trap representations (all bit patterns valid).
2026-03-15 22:41:15 -10:00
J. Nick Koston 70733fa913 [core] Fix Callback invocation for function pointer callables
Use (*ptr)(args...) instead of ptr->operator()(args...) so the
inline path works correctly for function pointers, which are
trivially copyable and pointer-sized but lack operator().
2026-03-15 22:39:31 -10:00
J. Nick Koston 3cebea9538 [core] Use __builtin_memcpy in Callback::create for cleaner code
Replace char-by-char loops with __builtin_memcpy in the inline
Callback storage path. Generates identical code but is cleaner
and avoids clang-analyzer false positives without NOLINT annotations.
2026-03-15 22:38:11 -10:00
J. Nick Koston 3c90438947 [core] Convert remaining add_on_*_callback methods to templates
Convert all remaining component add_on_*_callback methods from
std::function to templates so lambdas flow through without wrapping.
This avoids a heap allocation regression where passing std::function
through Callback::create would heap-allocate the std::function itself.

Also add NOLINT annotations for clang-analyzer false positive on
byte-wise copy in Callback::create.
2026-03-15 22:36:48 -10:00
J. Nick Koston bfc5a210bc [core] Replace std::function with lightweight Callback in CallbackManager
Replace std::function with a lightweight type-erased Callback struct
(8 bytes on 32-bit vs 16 for std::function) in CallbackManager and
LazyCallbackManager. Using C++20 if constexpr, small trivially-copyable
callables like [this] lambdas (81% of all callback registrations) are
stored inline in the function pointer context without heap allocation.

This eliminates std::function null checks (and __throw_bad_function_call)
from all entity callback paths, and templatizes add_on_*_callback methods
across all entity types so lambdas flow through without being wrapped in
std::function first.

Also converts EntityStateBase from hand-rolled nullable CallbackManager
pointers to LazyCallbackManager for consistency.

Measured flash savings:
- ESP8266 simple:        -160 B
- ESP8266 ratgdo:        -592 B
- ESP32 IDF (large):     -456 B
- ESP32 IDF (minimal):   -212 B
2026-03-15 22:20:42 -10:00
tomaszduda23 414182fe6d [ble_nus] fix uart debug (#14850) 2026-03-15 21:08:05 -10:00
dependabot[bot] 2ee0df1da3 Bump aioesphomeapi from 44.5.1 to 44.5.2 (#14849)
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2026-03-16 05:43:38 +00:00
Jonathan Swoboda e1252e32d1 [deep_sleep] Fix ESP-IDF 6.0 GPIO wakeup API rename (#14846) 2026-03-15 19:10:30 -10:00
Jonathan Swoboda 1183ef825b [usb_host] Fix ESP-IDF 6.0 compatibility for external USB host component (#14844) 2026-03-15 19:09:55 -10:00
Keith Burzinski c09edb94c1 [tinyusb] Fix regression from bump to 2.x in #14796 (#14848) 2026-03-16 00:04:07 -05:00
9948adc6a0 [runtime_image] Add esp-dsp dependency for JPEGDEC SIMD on ESP32 (#14840)
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
2026-03-15 18:15:01 -10:00
J. Nick Koston ccb467b219 [fastled] Include esp_lcd IDF component for ESP32-S3 compatibility (#14839) 2026-03-15 18:14:41 -10:00
J. Nick Koston 1377776d21 [ethernet] Restructure for multi-platform support (#14819) 2026-03-15 15:17:21 -10:00
J. Nick KostonandClaude Opus 4.6 29501ef4f8 [core] Mark leaf Component subclasses as final (#14833)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-15 15:13:34 -10:00
J. Nick Koston d97c23b8e3 [core] Add no-arg status_set_warning() to allow linker GC of const char* overload (#14821) 2026-03-15 15:13:10 -10:00
Bonne EgglestonandJ. Nick Koston 92d5e7b18c [tests] Fix integration helper to match entities exactly (#14837)
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
2026-03-15 13:02:23 -10:00
Jesse Hills 15ce4b3616 Merge branch 'beta' into dev 2026-03-16 11:46:15 +13:00
Jesse Hills 254e1f3abb Merge pull request #14834 from esphome/bump-2026.3.0b2
2026.3.0b2
2026.3.0b2
2026-03-16 11:45:42 +13:00
Jesse Hills deb6b97eea Bump version to 2026.3.0b2 2026-03-16 09:25:21 +13:00
J. Nick Koston 22ea2764d4 [debug] Fix shared buffer between reset reason and wakeup cause (#14813) 2026-03-16 09:25:21 +13:00
J. Nick Koston 632dbc8fe8 [core] Inline LwIPLock as no-op on platforms without lwIP core locking (#14787) 2026-03-16 09:25:21 +13:00
leccelecce 98d9871620 [online_image] Log download duration in milliseconds instead of seconds (#14803) 2026-03-16 09:25:21 +13:00
J. Nick Koston a064eceb9b [template] Fix misleading 'Text value too long to save' warning (#14753) 2026-03-16 09:25:21 +13:00
J. Nick Koston 49107f2174 [api] Increase log Nagle coalescing on all platforms except ESP8266 (#14752) 2026-03-16 09:25:21 +13:00
J. Nick Koston e9c2659147 [select] Fix -Wmaybe-uninitialized warnings on ESP8266 (#14759) 2026-03-16 09:25:20 +13:00
Kjell Braden 18b54f075e [runtime_image] fix BMP parsing (#14762) 2026-03-16 09:25:20 +13:00
J. Nick Koston 45e40223ac [rp2040] Fix compiler warnings in crash_handler and mdns (#14739) 2026-03-16 09:25:20 +13:00
J. Nick KostonandCopilot 1ab1534028 [mdns] Fix RP2040 mDNS not restarting after WiFi reconnect (#14737)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-16 09:25:20 +13:00
J. Nick Koston 039efdb02a [i2c] Fix RP2040 I2C bus selection based on pin assignment (#14745) 2026-03-16 09:25:20 +13:00
J. Nick Koston b0447dc521 [light] Fix binary light spamming 'brightness not supported' warning with strobe effect (#14735) 2026-03-16 09:25:20 +13:00
J. Nick Koston aacbaab5f8 [wifi] Reject EAP/WPA2 Enterprise config on unsupported platforms (#14746) 2026-03-16 09:25:20 +13:00
J. Nick Koston dc5032f72f [water_heater] Set OPERATION_MODE feature flag when modes are configured (#14748) 2026-03-16 09:25:20 +13:00
J. Nick KostonandCopilot c263c2c382 [captive_portal] Fix captive portal inaccessible when web_server auth is configured (#14734)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-16 09:25:20 +13:00
J. Nick Koston 910784ca84 [debug] Fix missing reset reason for RP2040/RP2350 (#14740) 2026-03-16 09:25:20 +13:00
J. Nick KostonandClaude Opus 4.6 0b99e8f08d [rp2040] Use full flash for sketch in testing mode (#14747)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16 09:25:20 +13:00