diff --git a/esphome/core/application.h b/esphome/core/application.h index 8b2f78beaa..46330cb2ae 100644 --- a/esphome/core/application.h +++ b/esphome/core/application.h @@ -572,6 +572,9 @@ class Application { void calculate_looping_components_(); + // These methods are called by Component::disable_loop() and Component::enable_loop() + // Components should not call these directly - use this->disable_loop() or this->enable_loop() + // to ensure component state is properly updated along with the loop partition void disable_component_loop(Component *component); void enable_component_loop(Component *component); diff --git a/esphome/core/component.h b/esphome/core/component.h index f787520026..e2adb66c47 100644 --- a/esphome/core/component.h +++ b/esphome/core/component.h @@ -155,6 +155,9 @@ class Component { * * This is useful for components that only need to run for a certain period of time * or when inactive, saving CPU cycles. + * + * @note Components should call this->disable_loop() on themselves, not on other components. + * This ensures the component's state is properly updated along with the loop partition. */ void disable_loop(); @@ -162,6 +165,9 @@ class Component { * * This is useful for components that transition between active and inactive states * and need to re-enable their loop() method when becoming active again. + * + * @note Components should call this->enable_loop() on themselves, not on other components. + * This ensures the component's state is properly updated along with the loop partition. */ void enable_loop();