From d96e8a9c4b47469688085016c99fc24b3dfc4fd8 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 6 Nov 2025 17:43:52 -0600 Subject: [PATCH] dry --- esphome/components/wifi/wifi_component.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/esphome/components/wifi/wifi_component.cpp b/esphome/components/wifi/wifi_component.cpp index 0ac675c0a3..4a76603691 100644 --- a/esphome/components/wifi/wifi_component.cpp +++ b/esphome/components/wifi/wifi_component.cpp @@ -349,10 +349,10 @@ void WiFiComponent::clear_sta() { } WiFiAP WiFiComponent::build_wifi_ap_from_selected_() const { - WiFiAP params = this->get_sta(); // PRECONDITION: selected_sta_index_ must be valid (ensured by all callers) - // If SSID is empty, it means selected_sta_index_ was invalid - this is a bug - assert(!params.get_ssid().empty()); + const WiFiAP *config = this->get_selected_sta_(); + assert(config != nullptr); + WiFiAP params = *config; // SYNCHRONIZATION: selected_sta_index_ and scan_result_[0] are kept in sync: // - wifi_scan_done() sorts all scan results by priority/RSSI (best first)