diff --git a/esphome/components/wifi/wifi_component.cpp b/esphome/components/wifi/wifi_component.cpp index 3448ce156e..d495efc82c 100644 --- a/esphome/components/wifi/wifi_component.cpp +++ b/esphome/components/wifi/wifi_component.cpp @@ -1591,7 +1591,9 @@ void WiFiComponent::check_connecting_finished(uint32_t now) { // (e.g., first connect failed but scan-based retry found and connected to the same better AP) bssid_t current_bssid = this->wifi_bssid(); if (this->roaming_target_bssid_ != bssid_t{} && current_bssid == this->roaming_target_bssid_) { - ESP_LOGD(TAG, "Roam successful (via retry)"); + char bssid_buf[MAC_ADDRESS_PRETTY_BUFFER_SIZE]; + format_mac_addr_upper(current_bssid.data(), bssid_buf); + ESP_LOGD(TAG, "Roam successful (via retry) to %s", bssid_buf); this->roaming_attempts_ = 0; } else { // Failed roam, reconnected to different AP - keep attempts to prevent ping-pong @@ -1603,6 +1605,7 @@ void WiFiComponent::check_connecting_finished(uint32_t now) { } this->roaming_state_ = RoamingState::IDLE; this->roaming_target_bssid_ = {}; + this->roaming_scan_end_ = 0; // Clear all priority penalties - the next reconnect will happen when an AP disconnects, // which means the landscape has likely changed and previous tracked failures are stale diff --git a/esphome/components/wifi/wifi_component.h b/esphome/components/wifi/wifi_component.h index 8c7e1f9be6..99b23436f7 100644 --- a/esphome/components/wifi/wifi_component.h +++ b/esphome/components/wifi/wifi_component.h @@ -790,8 +790,7 @@ class WiFiComponent final : public Component { uint32_t last_connected_{0}; uint32_t reboot_timeout_{}; uint32_t roaming_last_check_{0}; - uint32_t roaming_scan_end_{0}; // Timestamp when last roaming scan completed - bssid_t roaming_target_bssid_{}; // BSSID of the AP we're trying to roam to + uint32_t roaming_scan_end_{0}; // Timestamp when last roaming scan completed #ifdef USE_WIFI_AP uint32_t ap_timeout_{}; #endif @@ -816,6 +815,7 @@ class WiFiComponent final : public Component { bool error_from_callback_{false}; RetryHiddenMode retry_hidden_mode_{RetryHiddenMode::BLIND_RETRY}; RoamingState roaming_state_{RoamingState::IDLE}; + bssid_t roaming_target_bssid_{}; // BSSID of the AP we're trying to roam to #if defined(USE_ESP32) && defined(USE_WIFI_RUNTIME_POWER_SAVE) WiFiPowerSaveMode configured_power_save_{WIFI_POWER_SAVE_NONE}; #endif