mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-22 19:23:34 +00:00
Fix wifi scan re-querying error (#891)
This commit is contained in:
parent
46338ee21d
commit
3fc131dfd2
@ -512,26 +512,13 @@ class SmartDevice(Device, Bulb, Fan):
|
||||
bssid=res["bssid"],
|
||||
)
|
||||
|
||||
async def _query_networks(networks=None, start_index=0):
|
||||
_LOGGER.debug("Querying networks using start_index=%s", start_index)
|
||||
if networks is None:
|
||||
networks = []
|
||||
_LOGGER.debug("Querying networks")
|
||||
|
||||
resp = await self.protocol.query(
|
||||
{"get_wireless_scan_info": {"start_index": start_index}}
|
||||
)
|
||||
network_list = [
|
||||
_net_for_scan_info(net)
|
||||
for net in resp["get_wireless_scan_info"]["ap_list"]
|
||||
]
|
||||
networks.extend(network_list)
|
||||
|
||||
if resp["get_wireless_scan_info"].get("sum", 0) > start_index + 10:
|
||||
return await _query_networks(networks, start_index=start_index + 10)
|
||||
|
||||
return networks
|
||||
|
||||
return await _query_networks()
|
||||
resp = await self.protocol.query({"get_wireless_scan_info": {"start_index": 0}})
|
||||
networks = [
|
||||
_net_for_scan_info(net) for net in resp["get_wireless_scan_info"]["ap_list"]
|
||||
]
|
||||
return networks
|
||||
|
||||
async def wifi_join(self, ssid: str, password: str, keytype: str = "wpa2_psk"):
|
||||
"""Join the given wifi network.
|
||||
|
Loading…
Reference in New Issue
Block a user