Commit Graph
3098 Commits
Author SHA1 Message Date
J. Nick Koston a6c76f9b97 Merge branch 'scheduler-raw-pointers' into integration 2026-03-08 00:21:51 -10:00
J. Nick Koston 982998c8fb [scheduler] Replace unique_ptr with raw pointers, add leak detection
The scheduler was already managing SchedulerItem lifecycle explicitly
through its object pool (recycle_item_main_loop_ / get_item_from_pool_locked_).
The unique_ptr wrapper added overhead (11 destructor call sites on the hot path)
without providing safety — if a lifecycle path was missed, the unique_ptr would
silently delete the item and cause needless heap allocations instead of pool reuse.

Replace unique_ptr<SchedulerItem, SchedulerItemDeleter> with raw SchedulerItem*
throughout. Every item is now explicitly recycled to the pool or deleted via
delete_item_(). This eliminates all 11 unique_ptr destructor calls from the hot
path and saves ~256 bytes of firmware.

Add debug leak detection under ESPHOME_DEBUG_SCHEDULER: a live-item counter
verified at the end of every call() cycle asserts that all allocated items are
accounted for in items_, to_add_, defer_queue_, or the pool. This turns silent
heap churn from missed lifecycle management into an immediate assert failure
caught by integration tests.

Also moves the retry-cancelled check before item allocation in set_timer_common_
to avoid needless alloc+delete on the cold retry path, and fixes a thread-safety
issue where recycle_item_main_loop_ (main-loop-only) was called from
set_timer_common_ which can run on non-main-loop threads.

Enable debug_scheduler: true in all 18 scheduler integration test fixtures.
2026-03-08 00:08:22 -10:00
Keith BurzinskiJ. Nick Kostonpre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>J. Nick Koston
0c4a44566f [serial_proxy] New component (#13944)
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
2026-03-08 03:55:49 -05:00
J. Nick Koston 36755d6a08 Merge remote-tracking branch 'upstream/dev' into integration 2026-03-07 21:17:44 -10:00
tomaszduda23CopilotJ. Nick KostonJ. Nick Kostonpre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
e4b89a69d4 [nrf52, ota] ble and serial OTA based on mcumgr (#11932)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: J. Nick Koston <nick+github@koston.org>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
2026-03-07 20:32:20 -10:00
J. Nick Koston 84e5825fd1 Merge remote-tracking branch 'upstream/proto-byte-buffer' into integration 2026-03-07 19:46:15 -10:00
J. Nick Koston f7aeaad929 [api] Replace std::vector<uint8_t> with APIBuffer to skip zero-fill
Replace std::vector<uint8_t> with a minimal APIBuffer class for the
shared protobuf write buffer, frame helper receive buffer (rx_buf_),
and noise handshake prologue buffer.

std::vector::resize() zero-fills new bytes via memset. Every byte is
immediately overwritten by the protobuf encoder or socket reads,
making the zero-fill pure waste. APIBuffer skips zero-initialization
on resize() and uses make_unique_for_overwrite where available.

Also removes a dead write_raw_ template overload from api_frame_helper.h.
2026-03-07 19:45:50 -10:00
Keith BurzinskiJ. Nick Kostonpre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
5e842a8b20 [uart] Return flush result, expose timeout via config (#14608)
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: pre-commit-ci-lite[bot] <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com>
2026-03-08 05:23:13 +00:00
J. Nick Koston 543e9b9b54 Merge remote-tracking branch 'upstream/fix-modbus-usb-uart-timeout' into integration 2026-03-07 18:28:07 -10:00
J. Nick Koston e6d222959b Merge remote-tracking branch 'upstream/ld2450-integration-tests' into integration 2026-03-07 18:27:54 -10:00
J. Nick Koston 3b4897381f Address review feedback
- Avoid unnecessary vector construction in static mode path
- Use wraparound-safe millis comparison for staged RX
- Fix stale comments (20ms -> 40ms, ESP-IDF -> ESP32)
- Clarify MODBUS_BITS_PER_CHAR is approximate
2026-03-07 18:25:33 -10:00
J. Nick Koston 5319b8593b Add latency simulation to uart_mock for USB UART test
Add inject_to_rx_buffer_delayed() to uart_mock which stages bytes
that aren't visible to available() until the delay elapses. This
simulates USB packet delivery latency.

The test uses a 40ms delay which is:
- Greater than the old ~2ms timeout (fails without fix)
- Less than the new 50ms fallback timeout (passes with fix)
2026-03-07 18:07:18 -10:00
J. Nick Koston ab08aa7553 fix hostname len 2026-03-07 17:51:56 -10:00
J. Nick Koston c4b26fd3f5 Add integration test for non-hardware UART and extract constants
- Add test fixture simulating USB UART (no rx_full_threshold set)
  with a 20ms gap between response chunks
- Make rx_full_threshold optional in uart_mock
- Extract MODBUS_BITS_PER_CHAR and MS_PER_SEC constexprs
2026-03-07 17:41:56 -10:00
J. Nick Koston 72232c95d8 Use YAML anchors for filter dedup, add missing assertion, fix dummy baud rate 2026-03-07 17:13:06 -10:00
J. Nick Koston d8915da9cc [ld2450] Add integration tests with mock UART 2026-03-07 17:03:16 -10:00
J. Nick Koston da8de59bcb Merge remote-tracking branch 'upstream/proto-byte-buffer' into integration 2026-03-07 13:38:26 -10:00
J. Nick Koston 2a1af73d6f Merge branch 'dev' into proto-byte-buffer 2026-03-07 13:34:15 -10:00
J. Nick Koston 888f3d804b [ld2420] Add integration tests with mock UART (#14471) 2026-03-07 13:22:50 -10:00
Oliver Kleinecke f2dfb5e1dc [uart][usb_uart] Add debug_prefix option to distinguish multiple defined uarts in log (#14525) 2026-03-08 10:16:12 +11:00
J. Nick Koston 4ce1c3ffd9 [api] Also fall back to make_unique on LN882x; add LN882x test config 2026-03-07 08:42:32 -10:00
J. Nick Koston 0867866317 [api] Also fall back to make_unique on LN882x; add LN882x test config 2026-03-07 08:42:22 -10:00
J. Nick KostonandClaude Opus 4.6 45f20d9c06 [core] Merge set_name + set_entity_strings into configure_entity_ (#14444)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-07 07:26:01 -10:00
J. Nick Koston abc870006c [captive_portal] Enable support for RP2040 (#14505) 2026-03-07 07:25:13 -10:00
J. Nick Koston 1336198423 Merge branch 'warn-crystal-mismatch' into integration
# Conflicts:
#	tests/unit_tests/test_util.py
2026-03-06 22:45:07 -10:00
J. Nick KostonandClaude Opus 4.6 696c0f021c Patch at import point instead of subprocess.run
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 22:38:44 -10:00
J. Nick KostonandClaude Opus 4.6 9f72d5e428 Add test for run_external_process line_callbacks coverage
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-06 22:35:33 -10:00
J. Nick Koston dc4506453e Add tests for crystal callback wiring in upload_using_esptool
Tests both the in-process (run_external_command) and subprocess
(run_external_process) paths to ensure line_callbacks are passed.
2026-03-06 22:29:23 -10:00
J. Nick Koston 511e47b0f5 Remove unnecessary CORE mock from tests
CORE.reset() is called after each test via the reset_core fixture,
and CORE.dashboard defaults to False, so patching is not needed.
2026-03-06 22:26:12 -10:00
J. Nick Koston ae8dabc41a Add test for run_external_command with line_callbacks 2026-03-06 22:25:18 -10:00
J. Nick Koston c2747a6d35 Add tests and use walrus operator for crystal freq check 2026-03-06 22:09:52 -10:00
J. Nick Koston 0558815498 Merge remote-tracking branch 'origin/bluetooth-connection-params-api' into integration 2026-03-06 21:09:03 -10:00
AndreKRandJonathan Swoboda f53ee70caa [http_request] Make TLS buffer configurable on ESP8266 (#14009)
Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
2026-03-06 14:29:20 -10:00
J. Nick Koston 83e01035c9 Merge branch 'protect_entity_setters' into integration 2026-03-06 11:19:02 -10:00
J. Nick Koston 2852d86a2f Address review: robust regex and comment accuracy
- Fix extract_packed_value regex to handle commas in entity names
  by matching C++ string literals instead of [^,]+
- Only describe dc/uom/icon in comments when their index is actually
  non-zero, so comment matches what was packed
2026-03-06 11:18:11 -10:00
J. Nick Koston c1c73dd619 Merge remote-tracking branch 'upstream/protect_entity_setters' into integration
# Conflicts:
#	tests/component_tests/binary_sensor/test_binary_sensor.py
#	tests/component_tests/button/test_button.py
#	tests/component_tests/text/test_text.py
#	tests/component_tests/text_sensor/test_text_sensor.py
2026-03-06 11:16:34 -10:00
J. Nick Koston c956b33e93 Add comment noting shift correctness is verified by integration test 2026-03-06 11:02:35 -10:00
J. Nick Koston 86dd579dea Remove internal shift constants from unit tests
Tests now verify packed values via comment strings and non-zero
checks rather than decoding individual bit positions. This removes
the coupling to internal bit layout constants.
2026-03-06 11:00:19 -10:00
J. Nick Koston 41c413d5f7 Move extract_packed_value to shared component test helper
Add tests/component_tests/helpers.py with typed extract_packed_value()
and INTERNAL_BIT constant, replacing 5 duplicate copies.
2026-03-06 10:56:51 -10:00
J. Nick Koston c704d97804 Strengthen internal flag assertions in component tests
All internal-flag tests now extract the packed value and verify
bit 24 is set/clear for the correct entities, instead of just
checking configure_entity_() call presence.
2026-03-06 10:54:19 -10:00
J. Nick Koston b6b1378019 Strengthen internal flag assertions in component tests
All internal-flag tests now extract the packed value and verify
bit 24 is set/clear for the correct entities, instead of just
checking configure_entity_() call presence.
2026-03-06 10:54:06 -10:00
J. Nick Koston dffb964e0c Merge branch 'protect_entity_setters' into integration 2026-03-06 09:56:13 -10:00
J. Nick Koston 54a8f558d6 Convert finalize tests to end-to-end through public API
Tests now go through _setup_entity_impl + setup_device_class/
setup_unit_of_measurement + finalize_entity_strings using real
CONF_* keys instead of internal _KEY_* constants.
2026-03-06 09:51:26 -10:00
J. Nick Koston c37f1481ce Derive entity category names from cv.ENTITY_CATEGORIES and cleanup
- Remove hardcoded _ENTITY_CATEGORY_NAMES dict, derive from cv.ENTITY_CATEGORIES keys
- Remove redundant local import re (already at top level)
- Remove last setup_test_environment noqa line
2026-03-06 09:46:28 -10:00
J. Nick Koston dccc008383 Merge branch 'configure_entity' into protect_entity_setters 2026-03-06 09:44:16 -10:00
J. Nick Koston 69386cce2b Strengthen test assertions for configure_entity_ packed values
- Sensor and text_sensor device_class tests now extract and verify the
  packed argument is non-zero instead of just checking call presence
- Remove useless setup_test_environment fixture references in unit tests
2026-03-06 09:43:07 -10:00
J. Nick Koston 7117ded6b6 [core] Pack entity flags into configure_entity_() and protect setters
Move set_internal(), set_disabled_by_default(), set_entity_category(),
and set_device() to protected on EntityBase. These were codegen-only
setters never intended for runtime use.

internal, disabled_by_default, and entity_category are now packed into
the existing configure_entity_() uint32 parameter alongside string
indices, eliminating up to 3 separate function calls per entity.

set_device() is renamed to set_device_() per protected naming convention
and remains a separate call (pointer can't be packed).

Entity category integer mapping is derived from cv.ENTITY_CATEGORIES
to stay in sync with the C++ enum automatically.
2026-03-06 09:35:30 -10:00
J. Nick Koston 379e0b060f Merge branch 'configure_entity' into integration
# Conflicts:
#	esphome/components/api/api_connection.cpp
#	esphome/components/api/api_connection.h
#	esphome/core/application.h
#	esphome/core/config.py
#	esphome/core/entity_base.h
2026-03-06 08:47:29 -10:00
J. Nick Koston fd19bb4aa3 Merge remote-tracking branch 'upstream/dev' into configure_entity
# Conflicts:
#	esphome/core/entity_base.h
2026-03-06 08:40:31 -10:00
J. Nick KostonandCopilot 8a915dcbbe [core] Move device class strings to PROGMEM on ESP8266 (#14443)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2026-03-06 08:34:27 -10:00