You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/architecture/components/advanced.md
+54-2Lines changed: 54 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -253,6 +253,58 @@ To debug loop control issues:
253
253
254
254
3. Use the Logger component's async support as a reference implementation
255
255
256
-
### See Also
256
+
##Waking the Main Loop from Background Threads
257
257
258
-
- Source: [`esphome/core/component.h`](https://github.com/esphome/esphome/blob/dev/esphome/core/component.h) and [`esphome/core/component.cpp`](https://github.com/esphome/esphome/blob/dev/esphome/core/component.cpp)
258
+
For components that receive events in background threads/FreeRTOS tasks (BLE callbacks, network events, platform callbacks, etc.) and need low-latency processing, use `App.wake_loop_threadsafe()` to immediately wake the main loop instead of waiting 0-16ms for the next select() timeout.
259
+
260
+
**Platform Support:** ESP32 (ESP-IDF) and LibreTiny only.
261
+
262
+
### Setup
263
+
264
+
Add socket dependency in your component's `__init__.py`:
265
+
266
+
```python
267
+
AUTO_LOAD= ["socket"]
268
+
269
+
from esphome.components import socket
270
+
271
+
asyncdefto_code(config):
272
+
# Enable wake support
273
+
socket.require_wake_loop_threadsafe()
274
+
```
275
+
276
+
### Usage
277
+
278
+
Call from background thread/FreeRTOS task context (not ISR context):
0 commit comments