From 58b4e7dab2791e2cec7b87ad7fae015989481044 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 4 Jul 2025 20:54:46 +0000 Subject: [PATCH 1/2] Bump puremagic from 1.29 to 1.30 (#9320) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index c4dae9792d..a6bcebaeea 100644 --- a/requirements.txt +++ b/requirements.txt @@ -15,7 +15,7 @@ click==8.1.7 esphome-dashboard==20250514.0 aioesphomeapi==34.1.0 zeroconf==0.147.0 -puremagic==1.29 +puremagic==1.30 ruamel.yaml==0.18.14 # dashboard_import esphome-glyphsets==0.2.0 pillow==10.4.0 From 7d3a11a735b2a0177b04d73323054faf1a6fa4f3 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 4 Jul 2025 20:30:04 -0500 Subject: [PATCH 2/2] Add const char overload for Component::defer() --- esphome/core/component.cpp | 3 +++ esphome/core/component.h | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/esphome/core/component.cpp b/esphome/core/component.cpp index aba5dc729c..9ef30081aa 100644 --- a/esphome/core/component.cpp +++ b/esphome/core/component.cpp @@ -248,6 +248,9 @@ bool Component::cancel_defer(const std::string &name) { // NOLINT void Component::defer(const std::string &name, std::function &&f) { // NOLINT App.scheduler.set_timeout(this, name, 0, std::move(f)); } +void Component::defer(const char *name, std::function &&f) { // NOLINT + App.scheduler.set_timeout(this, name, 0, std::move(f)); +} void Component::set_timeout(uint32_t timeout, std::function &&f) { // NOLINT App.scheduler.set_timeout(this, "", timeout, std::move(f)); } diff --git a/esphome/core/component.h b/esphome/core/component.h index ab30466e2d..3734473a02 100644 --- a/esphome/core/component.h +++ b/esphome/core/component.h @@ -380,6 +380,21 @@ class Component { */ void defer(const std::string &name, std::function &&f); // NOLINT + /** Defer a callback to the next loop() call with a const char* name. + * + * IMPORTANT: The provided name pointer must remain valid for the lifetime of the deferred task. + * This means the name should be: + * - A string literal (e.g., "update") + * - A static const char* variable + * - A pointer with lifetime >= the deferred execution + * + * For dynamic strings, use the std::string overload instead. + * + * @param name The name of the defer function (must have static lifetime) + * @param f The callback + */ + void defer(const char *name, std::function &&f); // NOLINT + /// Defer a callback to the next loop() call. void defer(std::function &&f); // NOLINT