From a8f253eecf8e62815e8fc05362f498694ef6ad30 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Tue, 11 Nov 2025 16:02:01 -0600 Subject: [PATCH] tweaks on failure paths --- esphome/components/wifi/wifi_component.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/esphome/components/wifi/wifi_component.cpp b/esphome/components/wifi/wifi_component.cpp index 90a0186a70..0b98e07c1b 100644 --- a/esphome/components/wifi/wifi_component.cpp +++ b/esphome/components/wifi/wifi_component.cpp @@ -726,11 +726,12 @@ void WiFiComponent::start_connecting(const WiFiAP &ap) { if (!this->wifi_sta_connect_(ap)) { ESP_LOGE(TAG, "wifi_sta_connect_ failed"); - this->retry_connect(); - return; + // Enter cooldown to allow WiFi hardware to stabilize + // (immediate failure suggests hardware not ready, different from connection timeout) + this->state_ = WIFI_COMPONENT_STATE_COOLDOWN; + } else { + this->state_ = WIFI_COMPONENT_STATE_STA_CONNECTING; } - - this->state_ = WIFI_COMPONENT_STATE_STA_CONNECTING; this->action_started_ = millis(); } @@ -1413,10 +1414,6 @@ void WiFiComponent::advance_to_next_target_or_increment_retry_() { } void WiFiComponent::retry_connect() { - // We always need to be in STA_CONNECTING state to start a connection attempt - // If we start a scan here, we will set state to SCANNING - this->state_ = WIFI_COMPONENT_STATE_STA_CONNECTING; - this->log_and_adjust_priority_for_failed_connect_(); // Determine next retry phase based on current state