Commit Graph

13690 Commits

Author SHA1 Message Date
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
J. Nick Koston 1377776d21 [ethernet] Restructure for multi-platform support (#14819) 2026-03-15 15:17:21 -10:00
J. Nick Koston 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 Eggleston 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 Koston 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 Koston 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 Koston 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
J. Nick Koston 93be539789 [light] Fix ambiguous set_effect overload for const char* (#14732) 2026-03-16 09:25:20 +13:00
Brian Kaufman 390bb0451f [OTA] Stage exact uploaded size for ESP8266 web OTA (gzip fix) (#14741) 2026-03-16 09:25:20 +13:00
J. Nick Koston 14c3e2d9d9 [api] Fix heap-buffer-overflow in protobuf message dump for StringRef (#14721) 2026-03-16 09:25:20 +13:00
J. Nick Koston 23c7e0f803 [uart] Allow hardware UART with single pin on RP2040 (#14725) 2026-03-16 09:25:20 +13:00
J. Nick Koston cb4d1d1b5e [api] Fix undefined behavior in noise handshake with empty rx buffer (#14722) 2026-03-16 09:25:20 +13:00
J. Nick Koston 2ba807efe8 [adc] Fix PICO_VSYS_PIN compile error on RP2350 boards (#14724) 2026-03-16 09:25:20 +13:00
J. Nick Koston c8cf9b74b1 [ota][socket] Fix ESP8266/RP2040 OTA timeout by using SO_RCVTIMEO instead of polling (#14675) 2026-03-16 09:25:19 +13:00
J. Nick Koston 33475703da [time] Fix settimeofday() failure on ESP8266 (#14707)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-16 09:25:19 +13:00
J. Nick Koston 1b7d0f9c0b [esp32_ble_client] Fix disconnect race that causes stuck connections (#14211)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-16 09:25:19 +13:00
J. Nick Koston 1d881ef6f4 [socket] Fast path for TCP_NODELAY bypasses lwip_setsockopt overhead (#14693) 2026-03-16 09:25:19 +13:00
J. Nick Koston 3a838d897f [socket] Fix use-after-free in LWIP PCB close/abort path (#14706) 2026-03-16 09:25:19 +13:00
Matthias König da130c900f [mqtt] Fixed permission denied error for client certificates on Windows (#13525)
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
2026-03-16 09:25:19 +13:00
Kevin Ahrendt 440734dadf [audio] Bump microOpus to v0.3.5 (#14727) 2026-03-16 09:25:19 +13:00
Brian Kaufman df2ddc47ec [web_server] use DETAIL_ALL in update_all_json_generator (#14711) 2026-03-16 09:25:19 +13:00
Keith Burzinski 4b1c4ba5c0 [ledc] Fix high-pressure crash & recovery (#14720) 2026-03-16 09:25:19 +13:00
Adam DeMuri 6002badb3c [modbus] Fix buffer overflow in modbus (#14719)
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
2026-03-16 09:25:19 +13:00