I’ve been investigating the performance of these solutions. It seems that using the Arduino WiFi functions in the lambda gets the results faster, whereas the global_wifi_component yields a result when the node reconnects, and then another result about 15 seconds later.
Here is the ESPHome code for both methods:
api:
services:
- service: scan_wifi
then:
- lambda: |-
wifi::global_wifi_component->start_scanning();
- service: reset_wifi
then:
- lambda: |-
WiFi.disconnect();
WiFi.scanNetworks();
WiFi.begin();