From 91bfa8d4faa6b4d1e4a73c263827e4514d4e658c Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Sat, 4 Apr 2026 10:37:35 -1000 Subject: [PATCH] Make wake_loop_any_context available on all platforms including host --- esphome/core/application.h | 2 -- esphome/core/component.cpp | 2 -- esphome/core/wake.h | 3 +++ 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/esphome/core/application.h b/esphome/core/application.h index 016b9f217a6..900c11966dd 100644 --- a/esphome/core/application.h +++ b/esphome/core/application.h @@ -560,10 +560,8 @@ class Application { static void wake_loop_isrsafe(int *px) { esphome::wake_loop_isrsafe(px); } #endif -#if defined(USE_ESP32) || defined(USE_LIBRETINY) || defined(USE_ESP8266) || defined(USE_RP2040) /// Wake from any context (ISR, thread, callback). static void wake_loop_any_context() { esphome::wake_loop_any_context(); } -#endif protected: friend Component; diff --git a/esphome/core/component.cpp b/esphome/core/component.cpp index 747ade87e83..814295fd208 100644 --- a/esphome/core/component.cpp +++ b/esphome/core/component.cpp @@ -311,11 +311,9 @@ void IRAM_ATTR HOT Component::enable_loop_soon_any_context() { // 8. Race condition with main loop is handled by clearing flag before processing this->pending_enable_loop_ = true; App.has_pending_enable_loop_requests_ = true; -#if defined(USE_ESP32) || defined(USE_LIBRETINY) || defined(USE_ESP8266) || defined(USE_RP2040) // Wake the main loop from sleep. Without this, the main loop would not // wake until the select/delay timeout expires (~16ms). Application::wake_loop_any_context(); -#endif } void Component::reset_to_construction_state() { if ((this->component_state_ & COMPONENT_STATE_MASK) == COMPONENT_STATE_FAILED) { diff --git a/esphome/core/wake.h b/esphome/core/wake.h index ce96aa0efc5..185b73b870d 100644 --- a/esphome/core/wake.h +++ b/esphome/core/wake.h @@ -94,6 +94,9 @@ void wakeable_delay(uint32_t ms); /// Host platform: wakes select() via UDP loopback socket. Defined in application.cpp. void wake_loop_threadsafe(); +/// Host: no ISR, just use threadsafe version. +inline void wake_loop_any_context() { wake_loop_threadsafe(); } + #endif } // namespace esphome