diff --git a/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp b/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp index 6ae5245f77..5339565a32 100644 --- a/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp +++ b/esphome/components/esp32_ble_tracker/esp32_ble_tracker.cpp @@ -567,8 +567,6 @@ void ESP32BLETracker::try_promote_discovered_clients_() { if (this->scanner_state_ == ScannerState::RUNNING) { ESP_LOGD(TAG, "Stopping scan to make connection"); - // A connect ends the scan period a window-change restart was continuing. - this->skip_next_scan_end_ = false; this->stop_scan_(); // Don't wait for scan stop complete - promote immediately. // This is safe because ESP-IDF processes BLE commands sequentially through its internal mailbox queue. @@ -577,6 +575,8 @@ void ESP32BLETracker::try_promote_discovered_clients_() { } ESP_LOGD(TAG, "Promoting client to connect"); + // A connect ends the scan period a window-change restart was continuing. + this->skip_next_scan_end_ = false; #ifdef USE_ESP32_BLE_SOFTWARE_COEXISTENCE this->update_coex_preference_(true); #endif