From 7ef6b486d2988099c39983813065dd194ee9515b Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sun, 21 Jun 2026 11:03:46 -0500 Subject: [PATCH] [core] Address review: per-phase scheduler ids, log wording, doc typo --- esphome/core/component.h | 2 +- tests/integration/fixtures/scheduler_pool.yaml | 7 +++++-- tests/integration/fixtures/scheduler_string_test.yaml | 2 +- tests/integration/test_scheduler_string_test.py | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/esphome/core/component.h b/esphome/core/component.h index a0945e53aa..1ae70371a1 100644 --- a/esphome/core/component.h +++ b/esphome/core/component.h @@ -448,7 +448,7 @@ class Component { * Similar to javascript's setTimeout(). Empty name means no cancelling possible. * * IMPORTANT: Do not rely on this having correct timing. This is only called from - * loop() and therefore can be significantly delay. If you need exact timing please + * loop() and therefore can be significantly delayed. If you need exact timing please * use hardware timers. * * IMPORTANT: The provided name pointer must remain valid for the lifetime of the scheduler item. diff --git a/tests/integration/fixtures/scheduler_pool.yaml b/tests/integration/fixtures/scheduler_pool.yaml index f3e8a0a396..a75d9dbcbc 100644 --- a/tests/integration/fixtures/scheduler_pool.yaml +++ b/tests/integration/fixtures/scheduler_pool.yaml @@ -156,6 +156,7 @@ script: // Simulate a burst of defer operations like ratgdo does with state updates // These should execute immediately and recycle quickly to the pool + // Phase-specific id range (0..9) so ids never collide with later phases for (int i = 0; i < 10; i++) { App.scheduler.set_timeout(component, static_cast(i), 0, [i]() { ESP_LOGD("test", "Defer %d executed", i); @@ -206,8 +207,9 @@ script: // Now create 8 new timeouts - they should reuse from pool when available int reuse_test_count = 8; + // Phase-specific id range (100..107) so ids never collide with other phases for (int i = 0; i < reuse_test_count; i++) { - App.scheduler.set_timeout(component, static_cast(i), 10 + i * 5, [i]() { + App.scheduler.set_timeout(component, static_cast(100 + i), 10 + i * 5, [i]() { ESP_LOGD("test", "Reuse test %d completed", i); }); } @@ -227,8 +229,9 @@ script: auto *component = id(test_sensor); int full_reuse_count = 10; + // Phase-specific id range (200..209) so ids never collide with other phases for (int i = 0; i < full_reuse_count; i++) { - App.scheduler.set_timeout(component, static_cast(i), 10 + i * 5, [i]() { + App.scheduler.set_timeout(component, static_cast(200 + i), 10 + i * 5, [i]() { ESP_LOGD("test", "Full reuse test %d completed", i); }); } diff --git a/tests/integration/fixtures/scheduler_string_test.yaml b/tests/integration/fixtures/scheduler_string_test.yaml index 3e148ec202..06e3a4c97c 100644 --- a/tests/integration/fixtures/scheduler_string_test.yaml +++ b/tests/integration/fixtures/scheduler_string_test.yaml @@ -129,7 +129,7 @@ script: }); static const char CANCEL_NAME_2[] = "cancel_test"; App.scheduler.cancel_timeout(component2, CANCEL_NAME_2); - ESP_LOGI("test", "Cancelled timeout using different string object"); + ESP_LOGI("test", "Cancelled timeout using different buffer with same content"); // Test 11: const char* name with defer class TestDynamicDeferComponent : public Component { diff --git a/tests/integration/test_scheduler_string_test.py b/tests/integration/test_scheduler_string_test.py index 783ed37c13..3bc3487432 100644 --- a/tests/integration/test_scheduler_string_test.py +++ b/tests/integration/test_scheduler_string_test.py @@ -99,7 +99,7 @@ async def test_scheduler_string_test( timeout_count += 1 # Check for cancel test - elif "Cancelled timeout using different string object" in clean_line: + elif "Cancelled timeout using different buffer with same content" in clean_line: cancel_test_done.set() # Check for final results