Do not do update() in discover_single (#542)

This commit is contained in:
sdb9696
2023-11-21 20:58:41 +00:00
committed by GitHub
parent 30f217b8ab
commit 27c4799adc
5 changed files with 80 additions and 23 deletions

View File

@@ -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(