diff --git a/esphome/core/application.cpp b/esphome/core/application.cpp index 73fa462e10..0c17c70161 100644 --- a/esphome/core/application.cpp +++ b/esphome/core/application.cpp @@ -116,7 +116,7 @@ void Application::setup() { // clear path always works and needs no reconciliation. Finally, set // APP_STATE_SETUP_COMPLETE so subsequent warning clears go through // the normal walk-and-clear path. - if (!this->any_component_has_status_flag(STATUS_LED_WARNING)) + if (!this->any_component_has_status_flag_(STATUS_LED_WARNING)) this->app_state_ &= ~STATUS_LED_WARNING; this->app_state_ |= APP_STATE_SETUP_COMPLETE; @@ -224,7 +224,7 @@ void HOT Application::feed_wdt(uint32_t time) { #endif } } -bool Application::any_component_has_status_flag(uint8_t flag) const { +bool Application::any_component_has_status_flag_(uint8_t flag) const { // Walk all components (not just looping ones) so non-looping components' // status bits are respected. Only called from the slow-path clear helpers // (status_clear_warning_slow_path_ / status_clear_error_slow_path_) on an diff --git a/esphome/core/application.h b/esphome/core/application.h index 2e5e937842..19c1a1ecdb 100644 --- a/esphome/core/application.h +++ b/esphome/core/application.h @@ -414,12 +414,6 @@ class Application { /// (bit 6) to avoid costing additional RAM. bool is_setup_complete() const { return (this->app_state_ & APP_STATE_SETUP_COMPLETE) != 0; } - /// Walk all registered components looking for any whose component_state_ - /// has the given flag set. Used by Component::status_clear_*_slow_path_() - /// to decide whether to clear the corresponding bit on this->app_state_ - /// (which is the app-wide "any component has this status" indicator). - bool any_component_has_status_flag(uint8_t flag) const; - // Helper macro for entity getter method declarations #ifdef USE_DEVICES #define GET_ENTITY_METHOD(entity_type, entity_name, entities_member) \ @@ -594,6 +588,12 @@ class Application { bool is_socket_ready_(int fd) const { return FD_ISSET(fd, &this->read_fds_); } #endif + /// Walk all registered components looking for any whose component_state_ + /// has the given flag set. Used by Component::status_clear_*_slow_path_() + /// (which is a friend) to decide whether to clear the corresponding bit on + /// this->app_state_ (the app-wide "any component has this status" indicator). + bool any_component_has_status_flag_(uint8_t flag) const; + /// Register a component, detecting loop() override at compile time. /// Uses HasLoopOverride which handles ambiguous &T::loop from multiple inheritance. template void register_component_(T *comp) { diff --git a/esphome/core/component.cpp b/esphome/core/component.cpp index 7605565658..8949b4b76d 100644 --- a/esphome/core/component.cpp +++ b/esphome/core/component.cpp @@ -417,7 +417,7 @@ void Component::status_clear_warning_slow_path_() { // by a transient component clear — Application::setup() reconciles // the warning bit once at the end before setting APP_STATE_SETUP_COMPLETE. // The set path is unchanged (set_status_flag_ still writes directly). - if (App.is_setup_complete() && !App.any_component_has_status_flag(STATUS_LED_WARNING)) + if (App.is_setup_complete() && !App.any_component_has_status_flag_(STATUS_LED_WARNING)) App.app_state_ &= ~STATUS_LED_WARNING; ESP_LOGW(TAG, "%s cleared Warning flag", LOG_STR_ARG(this->get_component_log_str())); } @@ -426,7 +426,7 @@ void Component::status_clear_error_slow_path_() { // STATUS_LED_ERROR is never artificially forced — it only ever lands // in app_state_ via a real set_status_flag_ call. So the walk-and-clear // path is always safe, including during setup. - if (!App.any_component_has_status_flag(STATUS_LED_ERROR)) + if (!App.any_component_has_status_flag_(STATUS_LED_ERROR)) App.app_state_ &= ~STATUS_LED_ERROR; ESP_LOGE(TAG, "%s cleared Error flag", LOG_STR_ARG(this->get_component_log_str())); }