From ad58b92abef4faad750a079f39273226057cf544 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 5 Sep 2025 22:08:32 -0500 Subject: [PATCH] more --- esphome/core/component.cpp | 20 +++++++++----------- esphome/core/component.h | 3 --- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/esphome/core/component.cpp b/esphome/core/component.cpp index f780778cb2..dd2419c9cb 100644 --- a/esphome/core/component.cpp +++ b/esphome/core/component.cpp @@ -280,26 +280,24 @@ bool Component::can_proceed() { return true; } bool Component::status_has_warning() const { return this->component_state_ & STATUS_LED_WARNING; } bool Component::status_has_error() const { return this->component_state_ & STATUS_LED_ERROR; } -void Component::status_set_warning_flag_() { +void Component::status_set_warning(const char *message) { // Don't spam the log. This risks missing different warning messages though. if ((this->component_state_ & STATUS_LED_WARNING) != 0) return; this->component_state_ |= STATUS_LED_WARNING; App.app_state_ |= STATUS_LED_WARNING; -} - -void Component::status_set_warning(const char *message) { - this->status_set_warning_flag_(); - if ((this->component_state_ & STATUS_LED_WARNING) != 0) - ESP_LOGW(TAG, "%s set Warning flag: %s", this->get_component_source(), - message ? message : LOG_STR_LITERAL("unspecified")); + ESP_LOGW(TAG, "%s set Warning flag: %s", this->get_component_source(), + message ? message : LOG_STR_LITERAL("unspecified")); } #ifdef USE_STORE_LOG_STR_IN_FLASH void Component::status_set_warning(const LogString *message) { - this->status_set_warning_flag_(); + // Don't spam the log. This risks missing different warning messages though. if ((this->component_state_ & STATUS_LED_WARNING) != 0) - ESP_LOGW(TAG, "%s set Warning flag: %s", this->get_component_source(), - message ? LOG_STR_ARG(message) : LOG_STR_LITERAL("unspecified")); + return; + this->component_state_ |= STATUS_LED_WARNING; + App.app_state_ |= STATUS_LED_WARNING; + ESP_LOGW(TAG, "%s set Warning flag: %s", this->get_component_source(), + message ? LOG_STR_ARG(message) : LOG_STR_LITERAL("unspecified")); } #endif void Component::status_set_error(const char *message) { diff --git a/esphome/core/component.h b/esphome/core/component.h index 38d77d1e40..f7d41665dd 100644 --- a/esphome/core/component.h +++ b/esphome/core/component.h @@ -245,9 +245,6 @@ class Component { /// Helper to set component state (clears state bits and sets new state) void set_component_state_(uint8_t state); - /// Helper to set warning flag without duplicating logic - void status_set_warning_flag_(); - /** Set an interval function with a unique name. Empty name means no cancelling possible. * * This will call f every interval ms. Can be cancelled via CancelInterval().