From 886baab266745cdcb9559b62344c28764dfde75b Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 26 Sep 2025 15:00:43 -0500 Subject: [PATCH] guard --- esphome/components/esp32_improv/esp32_improv_component.cpp | 4 ++++ esphome/components/esp32_improv/esp32_improv_component.h | 2 ++ 2 files changed, 6 insertions(+) diff --git a/esphome/components/esp32_improv/esp32_improv_component.cpp b/esphome/components/esp32_improv/esp32_improv_component.cpp index e821950542..c5a0b89f99 100644 --- a/esphome/components/esp32_improv/esp32_improv_component.cpp +++ b/esphome/components/esp32_improv/esp32_improv_component.cpp @@ -195,6 +195,7 @@ void ESP32ImprovComponent::set_status_indicator_state_(bool state) { #endif } +#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_DEBUG const char *ESP32ImprovComponent::state_to_string_(improv::State state) { switch (state) { case improv::STATE_STOPPED: @@ -211,6 +212,7 @@ const char *ESP32ImprovComponent::state_to_string_(improv::State state) { return "UNKNOWN"; } } +#endif bool ESP32ImprovComponent::check_identify_() { uint32_t now = millis(); @@ -225,10 +227,12 @@ bool ESP32ImprovComponent::check_identify_() { } void ESP32ImprovComponent::set_state_(improv::State state) { +#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_DEBUG if (this->state_ != state) { ESP_LOGD(TAG, "State transition: %s (0x%02X) -> %s (0x%02X)", this->state_to_string_(this->state_), this->state_, this->state_to_string_(state), state); } +#endif this->state_ = state; if (this->status_ != nullptr && (this->status_->get_value().empty() || this->status_->get_value()[0] != state)) { this->status_->set_value(ByteBuffer::wrap(static_cast(state))); diff --git a/esphome/components/esp32_improv/esp32_improv_component.h b/esphome/components/esp32_improv/esp32_improv_component.h index cc4ea24a42..686da08111 100644 --- a/esphome/components/esp32_improv/esp32_improv_component.h +++ b/esphome/components/esp32_improv/esp32_improv_component.h @@ -108,7 +108,9 @@ class ESP32ImprovComponent : public Component { void process_incoming_data_(); void on_wifi_connect_timeout_(); bool check_identify_(); +#if ESPHOME_LOG_LEVEL >= ESPHOME_LOG_LEVEL_DEBUG const char *state_to_string_(improv::State state); +#endif }; // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)