Commit Graph
13913 Commits
Author SHA1 Message Date
J. Nick Koston 3fd28eeea2 [binary_sensor] Inline send_state_internal - virtual dispatch prevents template bloat 2026-03-22 16:38:38 -10:00
J. Nick Koston 0417de007a [binary_sensor] Restore virtual set_new_state, remove on_state_changed hook
Making set_new_state virtual means callers like send_state_internal
and invalidate_state resolve via vtable dispatch to the .cpp, avoiding
template bloat without needing out-of-line tricks or hiding declarations.

BinarySensor overrides set_new_state directly for logging and
ControllerRegistry notification, matching the original pattern.
2026-03-22 16:37:54 -10:00
J. Nick Koston 27d38baf0d [binary_sensor] Fix invalidate_state: keep inline on base, hide on BinarySensor
invalidate_state() can't be declaration-only on a template class.
Keep it inline on StatefulEntityBase, and add a hiding declaration
on BinarySensor with an out-of-line definition in the .cpp to prevent
template bloat from automation.h and filter.cpp callers.
2026-03-22 16:36:17 -10:00
J. Nick Koston df733708d5 Merge branch 'dev' into binary-sensor-remove-optional-state 2026-03-22 16:33:32 -10:00
J. Nick Koston a827410ecf [binary_sensor] Fix clang-tidy naming: no trailing underscore on virtual methods
- set_new_state → set_new_state_ (protected non-virtual, trailing underscore)
- on_state_changed_ → on_state_changed (virtual, no trailing underscore)
- set_state_value_ → set_state_value (virtual, no trailing underscore)

Update StatefulEntityBase docs to list on_state_changed and invalidate_state.
2026-03-22 16:27:34 -10:00
J. Nick Koston 98d9fd76b3 [mqtt] Fix const-correctness for trigger constructors (#15093) 2026-03-22 16:27:20 -10:00
J. Nick Koston 6992219e34 [core] Attribute placement new storage symbols to components (#15092) 2026-03-22 16:27:07 -10:00
J. Nick Koston 349f45f582 [binary_sensor] Move send_state_internal and invalidate_state to .cpp
set_new_state is a template method (~189 bytes when instantiated).
Inlining callers like send_state_internal and invalidate_state causes
the template code to be duplicated at every call site (publish_state,
Filter::output, BinarySensorInvalidateAction::play, etc.), adding
~384 bytes of flash.

Keep these as out-of-line definitions in the .cpp so the template
is instantiated once.
2026-03-22 16:26:16 -10:00
J. Nick Koston 58498bacff [binary_sensor] Skip old_state construction when no full_state_callbacks registered 2026-03-22 16:21:25 -10:00
J. Nick Koston 14c54597ce [binary_sensor] Make set_new_state non-virtual, add on_state_changed_ hook
set_new_state is only called internally. Making it non-virtual
eliminates a vtable entry and allows the compiler to inline it.

BinarySensor now overrides on_state_changed_() for logging and
ControllerRegistry notification instead of overriding set_new_state.
2026-03-22 16:20:29 -10:00
J. Nick Koston 5854fa1d82 [binary_sensor] Access flags_ directly in set_new_state to reduce flash 2026-03-22 16:17:35 -10:00
J. Nick Koston e28c9d191c [binary_sensor] Move send_state_internal to header for devirtualization 2026-03-22 16:16:59 -10:00
J. Nick Koston 2833401cc1 [binary_sensor] Simplify else-if in set_new_state 2026-03-22 16:15:24 -10:00
J. Nick Koston 1e2c5fbc4e [binary_sensor] Update state before firing callbacks in set_new_state
Move set_has_state and set_state_value_ before callback invocations
so callback code can inspect the entity's current state via
get_state()/has_state(). The old state is passed as a parameter.

Addresses Copilot review feedback.
2026-03-22 16:13:35 -10:00
J. Nick Koston db3cfaa3fc [binary_sensor] Reduce flash: un-inline send_state_internal, optimize set_new_state
Move send_state_internal back to .cpp to avoid duplicating it at each
call site (publish_state and Filter::output).

Optimize set_new_state to compare has_state + value directly instead
of constructing optional<T> on stack for the comparison. Optionals
are only constructed in the changed path for callbacks that need them.
2026-03-22 16:11:06 -10:00
J. Nick Koston fc1186895c [binary_sensor] Fix stale comment in StatefulEntityBase docs 2026-03-22 16:03:44 -10:00
J. Nick Koston 047a744ed3 [binary_sensor] Inline send_state_internal into header 2026-03-22 16:02:51 -10:00
J. Nick Koston e406fb25cb [binary_sensor] Move trigger_on_initial_state out of EntityBase flags into BinarySensor
Use pure virtual get/set methods on StatefulEntityBase instead of
storing the flag in EntityBase::flags_. This keeps EntityBase clean
and avoids mixing binary_sensor-specific state into the base entity.
2026-03-22 16:01:39 -10:00
J. Nick Koston 98b0aea6bf [binary_sensor] Restore comment on state member 2026-03-22 16:00:07 -10:00
J. Nick Koston 7754e517f2 [binary_sensor] Add documentation comments to StatefulEntityBase 2026-03-22 15:59:33 -10:00
J. Nick Koston 91944988ef [binary_sensor] Remove redundant optional<bool> state_ from StatefulEntityBase
Replace optional<T> state_ in StatefulEntityBase with pure virtual
get_state()/set_state_value_() that subclasses implement. BinarySensor
stores its value in the existing public bool state member and uses
EntityBase::flags_.has_state instead of the optional's discriminant.

Move trigger_on_initial_state_ into EntityBase::flags_ (1 bit from
reserved), eliminating the standalone bool and its padding.

Saves 8 bytes per BinarySensor instance:
- optional<bool> (2B) + padding (2B) = 4B removed
- bool trigger_on_initial_state_ (1B) + padding (3B) = 4B removed
2026-03-22 15:58:31 -10:00
J. Nick Koston fbe3e7d99c [api] Emit raw tag+value writes for forced fixed32 key fields (#15051) 2026-03-22 15:28:46 -10:00
J. Nick Koston 9cdc17566a [combination] Use FixedVector and parent pointer to enable inline Callback storage (#14947) 2026-03-22 15:06:45 -10:00
cd05462e9f [core] Use placement new allocation for Pvariables (#15079)
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
Co-authored-by: J. Nick Koston <nick@koston.org>
2026-03-22 14:42:04 -10:00
J. Nick KostonandClaude Opus 4.6 e85065b1c4 [logger] Fix dummy_main.cpp Logger constructor for clang-tidy (#15088)
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-22 14:06:00 -10:00
J. Nick Koston d0e705d948 [core] Inline Application::loop() to eliminate stack frame (#15041) 2026-03-22 12:46:28 -10:00
J. Nick Koston 2c06464f7b [packet_transport] Use FixedVector and parent pointer to enable inline Callback storage (#14946) 2026-03-22 12:41:54 -10:00
J. Nick Koston 84727b1f71 [esp32] Validate eFuse MAC reads and reject garbage MACs (#15049) 2026-03-22 12:41:01 -10:00
J. Nick Koston aef987dccf [core] Fix Callback::create memcpy from function reference (#14995) 2026-03-22 12:37:46 -10:00
J. Nick Koston b2b61bea6a [web_server_idf] Inline send() to reduce httpd task stack depth (#15045) 2026-03-22 12:33:06 -10:00
J. Nick Koston 30f66be1da [esp32] Mention ignore_pin_validation_error in flash pin error message (#14998) 2026-03-22 12:32:42 -10:00
J. Nick Koston 6caa9ee227 [logger] Move log level lookup tables to PROGMEM (#15003) 2026-03-22 12:32:08 -10:00
J. Nick Koston 9152f77cdd [core] Reduce automation call chain stack depth (#15042) 2026-03-22 12:31:48 -10:00
J. Nick Koston 4d09eb2cec [tests] Fix flaky ld24xx integration tests by disabling API batching (#15050) 2026-03-22 12:29:28 -10:00
J. Nick Koston 5cc4f6e85a [logger] Add task_log_buffer_zephyr.cpp to platform source filter (#15081) 2026-03-22 12:29:12 -10:00
J. Nick Koston 27f3a5f5f4 [sht4x] Add missing hal.h include for millis() on ESP-IDF (#15087) 2026-03-22 11:54:54 -10:00
J. Nick Koston 593dbc9e67 [logger] Fix unit test and benchmark Logger constructor calls (#15085) 2026-03-23 09:50:58 +13:00
J. Nick Koston daafa8faa3 [wifi] Inline trivial WiFiAP and WiFiComponent accessors (#15075) 2026-03-22 10:36:18 -10:00
Jason Kölker 2b6d63fd09 [pmsx003] Keep active-mode reads aligned (#14832) 2026-03-23 09:21:08 +13:00
J. Nick KostonCopilotpre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
c917b8ce06 [logger] Fix race condition in task log buffer initialization (#15071)
Co-authored-by: Copilot <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-23 09:20:28 +13:00
Jonathan Swoboda 12b10d8b89 [ultrasonic] Fix ISR edge detection with debounce and trigger filtering (#15014) 2026-03-22 16:19:46 -04:00
J. Nick Koston 6a77b8b1f4 [light] Fix gamma LUT quantizing small brightness to zero (#15060) 2026-03-23 09:19:28 +13:00
J. Nick Koston ba4be2a904 [uart] Fix RTL87xx compilation failure due to SUCCESS macro collision (#15054) 2026-03-23 09:17:59 +13:00
J. Nick Koston ca0523b86c [sht4x] Fix heater causing measurement jitter (#15030) 2026-03-23 09:16:46 +13:00
J. Nick KostonandCopilot 5e68282519 [light] Fix constant_brightness broken by gamma LUT refactor (#15048)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-23 09:14:52 +13:00
Clyde Stubbs a0d5525312 [lvgl] Meter fixes (#15073) 2026-03-22 19:01:49 +11:00
J. Nick Koston c48fd0738b [mqtt] Rate-limit component resends to prevent task WDT on reconnect (#15061) 2026-03-21 15:33:42 -10:00
J. Nick Koston 8224da3460 [core] Inline Component::get_component_log_str() (#15068) 2026-03-21 15:32:24 -10:00
Clyde Stubbs dd82a91d8f [lvgl] Don't animate page change when not requested (#15069) 2026-03-22 11:13:17 +11:00
J. Nick Koston 86ec218f75 [benchmark] Add plaintext API frame write benchmarks (#15036) 2026-03-21 13:15:35 -10:00