J. Nick Koston d507feaf81 [core] Scheduler::next_schedule_in: also handle single-threaded defer path
On ESPHOME_THREAD_SINGLE builds (ESP8266, RP2040), defer() does not
route through defer_queue_ — set_timer_common_ treats it as an ordinary
0-delay set_timeout that stages in to_add_ (scheduler.cpp:197). Since
next_schedule_in only inspects items_[0], any defer posted from a
component's loop() sits in to_add_ invisible to the sleep calculation
until the next scheduler.call() runs process_to_add().

The symmetric fix checks to_add_empty_() on single-threaded and
short-circuits sleep the same way. This also costs one "skipped sleep"
for any non-zero-delay timer added at runtime, but the next tick
produces a correct next_schedule_in reading and the cost is a single
yield — negligible vs. the stall this closes.

Suggested by Copilot review on #15968.
2026-04-24 03:37:11 -05:00
2023-06-12 17:00:34 +12:00
2022-09-06 15:48:01 +12:00
2025-12-21 09:26:03 -05:00
2024-03-28 10:20:51 +13:00
2025-07-17 22:40:28 +12:00
2025-12-08 14:37:45 -05:00
2026-04-09 11:28:48 +12:00
2025-07-17 22:40:28 +12:00
S
Description
ESPHome is a system to control your ESP8266/ESP32 by simple yet powerful configuration files and control them remotely through Home Automation systems.
Readme Multiple Licenses 545 MiB
Languages
C++ 60.1%
Python 39.3%
C 0.3%
JavaScript 0.2%