From 0eafe5259f00be1860943ed8234810f94b4872e3 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Thu, 6 Nov 2025 15:44:48 -0600 Subject: [PATCH] defensive to make bot happy --- esphome/components/wifi/wifi_component.cpp | 2 +- esphome/components/wifi/wifi_component.h | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/esphome/components/wifi/wifi_component.cpp b/esphome/components/wifi/wifi_component.cpp index 6e4611d765..131fd122d7 100644 --- a/esphome/components/wifi/wifi_component.cpp +++ b/esphome/components/wifi/wifi_component.cpp @@ -365,7 +365,7 @@ WiFiAP WiFiComponent::build_selected_ap_() const { // For hidden networks, clear BSSID and channel even if set in config // There might be multiple hidden networks with same SSID but we can't know which is correct // Rely on probe-req with just SSID. Empty channel triggers ALL_CHANNEL_SCAN. - // Note: Scan data is never used for hidden networks (see check below at line ~390) + // Note: Scan data is never used for hidden networks (see !params.get_hidden() check below) params.set_bssid(optional{}); params.set_channel(optional{}); } else { diff --git a/esphome/components/wifi/wifi_component.h b/esphome/components/wifi/wifi_component.h index 6cdab1660f..04adb57b44 100644 --- a/esphome/components/wifi/wifi_component.h +++ b/esphome/components/wifi/wifi_component.h @@ -358,7 +358,12 @@ class WiFiComponent : public Component { // Set selected sta with a temporary scan result (fast connect path) void set_selected_sta_with_scan_(int8_t sta_index, const WiFiScanResult &scan) { +#ifdef USE_RP2040 + this->scan_result_.clear(); + this->scan_result_.reserve(1); +#else this->scan_result_.init(1); +#endif this->scan_result_.push_back(scan); this->selected_sta_index_ = sta_index; }