adjust per review

This commit is contained in:
J. Nick Koston 2023-11-02 18:01:09 -05:00
parent 6573ee0f8a
commit bcdcd5f982
No known key found for this signature in database

View File

@ -341,12 +341,19 @@ class Discover:
:param host: Hostname of device to query
:param device_type: Device type to use for the device.
If not given, the device type is discovered by querying the device.
If the device type is already known, it is preferred to pass it
to avoid the extra query to the device to discover its type.
:rtype: SmartDevice
:return: Object for querying/controlling found device.
"""
if device_type and (klass := DEVICE_TYPE_TO_CLASS.get(device_type)):
dev = klass(host=host, port=port, credentials=credentials, timeout=timeout)
else:
dev: SmartDevice = klass(
host=host, port=port, credentials=credentials, timeout=timeout
)
await dev.update()
return dev
unknown_dev = SmartDevice(
host=host, port=port, credentials=credentials, timeout=timeout
)