Commit Graph

306 Commits

Author SHA1 Message Date
J. Nick Koston bc6691da9a Merge remote-tracking branch 'origin/rp2040-upload-improvements' into integration 2026-03-09 17:49:47 -10:00
Jonathan Swoboda c31ac662bd [multiple] Fix crashes from malformed external input (#14643)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
2026-03-09 20:39:58 -04:00
J. Nick Koston 9cc56b82a9 Merge remote-tracking branch 'upstream/dev' into integration
# Conflicts:
#	tests/integration/fixtures/uart_mock_ld2450.yaml
#	tests/integration/test_uart_mock_ld2450.py
2026-03-08 14:57:36 -10:00
J. Nick Koston aef2d74e41 [ld2450] Add integration tests with mock UART (#14611) 2026-03-08 14:32:59 -10:00
J. Nick Koston 88536ff72b [modbus] Fix timeout for non-hardware UARTs (e.g., USB UART) (#14614)
Co-authored-by: Clyde Stubbs <2366188+clydebarrow@users.noreply.github.com>
2026-03-08 14:31:42 -10:00
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
J. Nick Koston 84e5825fd1 Merge remote-tracking branch 'upstream/proto-byte-buffer' into integration 2026-03-07 19:46:15 -10:00
Keith Burzinski 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 888f3d804b [ld2420] Add integration tests with mock UART (#14471) 2026-03-07 13:22:50 -10:00
J. Nick Koston 191e5d70b5 Merge origin/log-skip-vprintf-indirection into integration 2026-03-05 22:12:26 -10:00
J. Nick Koston 1fa99305f9 [log] Enable ESPHOME_DEBUG in integration tests 2026-03-05 22:05:36 -10:00
J. Nick Koston 21fb5975d6 Merge remote-tracking branch 'upstream/dev' into integration
# Conflicts:
#	esphome/components/esphome/ota/ota_esphome.h
#	esphome/components/http_request/ota/ota_http_request.cpp
#	esphome/components/http_request/ota/ota_http_request.h
#	esphome/components/ota/ota_backend_factory.h
#	esphome/components/web_server/ota/ota_web_server.cpp
#	esphome/components/wifi/wifi_component.cpp
2026-03-05 10:57:44 -10:00
Bonne Eggleston b0be02e16d [modbus] Fix timing bugs and better adhere to spec (#8032)
Co-authored-by: brambo123 <52667932+brambo123@users.noreply.github.com>
Co-authored-by: Keith Burzinski <kbx81x@gmail.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
Co-authored-by: J. Nick Koston <nick+github@koston.org>
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
2026-03-05 20:54:17 +00:00
J. Nick Koston 97f7bd98a9 Merge remote-tracking branch 'upstream/dev' into integration 2026-03-04 16:45:10 -10:00
J. Nick Koston 5df4fd0a27 [tests] Fix flaky uart_mock integration tests (#14476) 2026-03-04 15:51:51 -10:00
J. Nick Koston 1f9bdb2197 Merge remote-tracking branch 'upstream/dev' into integration 2026-03-04 07:25:53 -10:00
J. Nick Koston b2e8544c58 [ld2412] Add integration tests with mock UART (#14448) 2026-03-04 07:18:31 -10:00
J. Nick Koston 395ab306bd Merge remote-tracking branch 'upstream/dev' into integration 2026-03-03 14:32:48 -10:00
Jonathan Swoboda ee78d7a0c0 [tests] Fix integration test race condition in PlatformIO cache init (#14435)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 17:42:41 -05:00
J. Nick Koston 7becceb3b1 Merge remote-tracking branch 'upstream/dev' into integration 2026-03-03 08:23:42 -10:00
Clyde Stubbs cfde0613bb [const][uart][usb_uart][weikai][core] Move constants to components/const (#14430) 2026-03-03 07:53:18 -05:00
J. Nick Koston 3afcbd22b2 Merge branch 'add-codeowner-approved-label' into integration 2026-03-02 16:02:28 -10:00
J. Nick Koston 2e623fd6c3 [tests] Fix flaky log assertion race in oversized payload tests (#14414) 2026-03-02 11:48:50 -10:00
J. Nick Koston 3615a7b90c [core] Eliminate __udivdi3 in millis() on ESP32 and RP2040 (#14409) 2026-03-02 11:42:25 -10:00
J. Nick Koston 8ee800bb35 Merge remote-tracking branch 'upstream/esp32-millis-euclidean-decomposition' into integration 2026-03-02 07:53:19 -10:00
J. Nick Koston 96a564a6e9 [core] Replace Python unit tests with C++ integration test for micros_to_millis
The Python tests were testing a Python reimplementation, not the
actual C++ code. Replace with an integration test that exercises
the real micros_to_millis() on the host platform, covering boundary
values, carry paths, and mod-8 shift edge cases (25 checks).
2026-03-02 07:41:52 -10:00
J. Nick Koston 309cda0799 Merge remote-tracking branch 'upstream/dev' into integration 2026-03-01 23:02:57 -10:00
Bonne Eggleston 3160457ca6 Create integration tests for modbus (#14395)
Co-authored-by: J. Nick Koston <nick@home-assistant.io>
2026-03-01 22:51:27 -10:00
J. Nick Koston 8f83f5c9fc Merge branch 'esp8266-wake-loop-any-context' into integration 2026-03-01 21:09:29 -10:00
J. Nick Koston 80a2acca4f [ld2410] Add UART mock integration test for LD2410 component (#14377) 2026-03-01 18:19:32 -10:00
J. Nick Koston 113b1554aa Merge remote-tracking branch 'upstream/dev' into integration 2026-02-25 17:39:57 -07:00
Jonathan Swoboda 0d5b7df77d [sensor] Fix delta filter percentage mode regression (#14302)
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
2026-02-25 19:32:02 -05:00
J. Nick Koston 8bb577de64 [api] Split ProtoVarInt::parse into 32-bit and 64-bit phases (#14039) 2026-02-25 12:23:13 -06:00
J. Nick Koston b539a5aa51 [water_heater] Fix device_id missing from state responses (#14212) 2026-02-22 23:07:56 +00:00
J. Nick Koston bd7e1e8526 Merge remote-tracking branch 'origin/fix-water-heater-device-id' into integration 2026-02-22 16:58:32 -06:00
J. Nick Koston cdb2e32518 [water_heater] Fix device_id missing from state responses
Water heater was the only entity type that directly called
encode_message_to_buffer() instead of fill_and_encode_entity_state().
This meant device_id was never set on WaterHeaterStateResponse,
causing entities with device_id to show as unknown in Home Assistant.

Expand the device_id integration test to cover all entity types:
cover, fan, lock, number, select, text, valve, water_heater,
alarm_control_panel, date, time, datetime, and event.

Closes https://github.com/esphome/esphome/issues/14206
2026-02-22 16:43:08 -06:00
J. Nick Koston 2873f7f8f3 Merge branch 'api_varint_split_32_64' into integration 2026-02-18 10:23:08 -06:00
J. Nick Koston bc2dbd3cf5 Add integration test for 5-byte varint device_id parsing
Device IDs are FNV hashes (uint32) that frequently exceed 2^28,
requiring 5 varint bytes. This test verifies the firmware correctly
decodes these values in incoming SwitchCommandRequest messages and
encodes them in state responses.
2026-02-18 08:35:00 -06:00
J. Nick Koston 80d16dda42 Merge remote-tracking branch 'upstream/dev' into integration 2026-02-12 15:20:20 -06:00
Jonathan Swoboda db7870ef5f [alarm_control_panel] Fix flaky integration test race condition (#13964)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-12 16:04:39 -05:00