mirror of
https://github.com/python-kasa/python-kasa.git
synced 2025-08-09 20:24:02 +00:00
Do not do update() in discover_single (#542)
This commit is contained in:
@@ -260,6 +260,7 @@ class Discover:
|
||||
port: Optional[int] = None,
|
||||
timeout=5,
|
||||
credentials: Optional[Credentials] = None,
|
||||
update_parent_devices: bool = True,
|
||||
) -> SmartDevice:
|
||||
"""Discover a single device by the given IP address.
|
||||
|
||||
@@ -271,8 +272,9 @@ class Discover:
|
||||
:param host: Hostname of device to query
|
||||
:param port: Optionally set a different port for the device
|
||||
:param timeout: Timeout for discovery
|
||||
:param credentials: Optionally provide credentials for
|
||||
devices requiring them
|
||||
:param credentials: Credentials for devices that require authentication
|
||||
:param update_parent_devices: Automatically call device.update() on
|
||||
devices that have children
|
||||
:rtype: SmartDevice
|
||||
:return: Object for querying/controlling found device.
|
||||
"""
|
||||
@@ -330,7 +332,9 @@ class Discover:
|
||||
if ip in protocol.discovered_devices:
|
||||
dev = protocol.discovered_devices[ip]
|
||||
dev.host = host
|
||||
await dev.update()
|
||||
# Call device update on devices that have children
|
||||
if update_parent_devices and dev.has_children:
|
||||
await dev.update()
|
||||
return dev
|
||||
elif ip in protocol.unsupported_devices:
|
||||
raise UnsupportedDeviceException(
|
||||
|
Reference in New Issue
Block a user