Subject: BLE client stops working after esp32_ble_tracker.stop_scan is called

Hi, I’m experiencing an issue in ESPHome where my BLE client stops working if I call esp32_ble_tracker.stop_scan. As soon as I stop the scan, the BLE client disconnects or fails to communicate.

Interestingly, if I test the exact same configuration but without including the esp32_ble_tracker component at all, the BLE client works fine — both the initial connection and reconnection behave as expected.

Is this expected behavior or a bug? Is there a recommended way to stop scanning without affecting the BLE client?

Thanks in advance for your help!

[18:45:32][I][jk_bms_ble:614]: Emergency switch: OFF
[18:45:32][D][sensor:093]: ‘jk-bms emergency time countdown’: Sending state 0.00000 s with 0 decimals of accuracy
[18:45:32][W][component:239]: Component lvgl took a long time for an operation (66 ms).
[18:45:32][W][component:240]: Components should block for at most 30 ms.
[18:45:32][D][esp32_ble_client:191]: [0] [C8:47:80:26:17:3C] ESP_GATTC_NOTIFY_EVT
[18:45:32][D][esp32_ble_client:191]: [0] [C8:47:80:26:17:3C] ESP_GATTC_NOTIFY_EVT
[18:45:33][D][esp32_ble_client:191]: [0] [C8:47:80:26:17:3C] ESP_GATTC_NOTIFY_EVT
[18:45:33][D][esp32_ble_client:191]: [0] [C8:47:80:26:17:3C] ESP_GATTC_NOTIFY_EVT
[18:45:33][D][esp32_ble_client:191]: [0] [C8:47:80:26:17:3C] ESP_GATTC_NOTIFY_EVT
[18:45:33][D][esp32_ble_client:191]: [0] [C8:47:80:26:17:3C] ESP_GATTC_NOTIFY_EVT
[18:45:39][D][esp-idf:000][BTU_TASK]: W (113963) BT_APPL: gattc_conn_cb: if=3 st=0 id=3 rsn=0x8
[18:45:39]
[18:45:39][D][esp-idf:000][BTU_TASK]: W (113964) BT_HCI: hcif disc complete: hdl 0x1, rsn 0x8
[18:45:39]
[18:45:39][D][esp32_ble_client:280]: [0] [C8:47:80:26:17:3C] ESP_GATTC_DISCONNECT_EVT, reason 8
[18:45:39][D][esp-idf:000][BTC_TASK]: E (113965) BT_APPL: BTA_GATTC_DeregisterForNotifications registration not found bd_addr:c8:47:80:26:17:3c
[18:45:39]
[18:45:39][D][esp32_ble_client:191]: [0] [C8:47:80:26:17:3C] ESP_GATTC_CLOSE_EVT
[18:45:39][D][esp32_ble_client:416]: [0] [C8:47:80:26:17:3C] Event 39
[18:45:43][W][jk_bms_ble:254]: [C8:47:80:26:17:3C] Not connected
[18:45:48][W][jk_bms_ble:254]: [C8:47:80:26:17:3C] Not connected
[18:45:53][W][jk_bms_ble:254]: [C8:47:80:26:17:3C] Not connected
[18:45:58][W][jk_bms_ble:254]: [C8:47:80:26:17:3C] Not connected
[18:46:03][W][jk_bms_ble:254]: [C8:47:80:26:17:3C] Not connected
[18:46:05][W][component:239]: Component lvgl took a long time for an operation (65 ms).
[18:46:05][W][component:240]: Components should block for at most 30 ms.
[18:46:08][W][jk_bms_ble:254]: [C8:47:80:26:17:3C] Not connected
[18:46:09][W][component:239]: Component lvgl took a long time for an operation (115 ms).
[18:46:09][W][component:240]: Components should block for at most 30 ms.
[18:46:13][W][jk_bms_ble:254]: [C8:47:80:26:17:3C] Not connected
[18:46:18][W][jk_bms_ble:254]: [C8:47:80:26:17:3C] Not connected