Issues running WiFi.scanNetworks() in ESPHome custom sensor (esp32)

I am trying to get a list of WiFi addresses and Mac Addresses / signal strength from an ESP32, similar to what happens during boot:

[22:19:54][D][wifi:304]: Starting scan...
[22:19:56][D][wifi:319]: Found networks:
[22:19:56][I][wifi:365]: - 'xxx' (Bxxx94) ▂▄▆█
[22:19:56][D][wifi:366]:     Channel: 1
[22:19:56][D][wifi:367]:     RSSI: -42 dB
[22:19:56][D][wifi:369]: - '' (C6:sf:243:as:6D:94) ▂▄▆█
[22:19:56][D][wifi:369]: - 'xxx-xx' (12:xx:24:C1:6D:94) ▂▄▆█
...

When ever I run WiFi.scanNetworks() I get a result of 0.
I’ve tried setting the WiFi mode to station and disconnecting the wifi before scanning, but nothing appears to change the outcome.

Does anyone know if getting this is possible if also using ESPHome firmware, or does something interfere with the scan?

Cheers.