Update try_connect_all to be more efficient and report attempts (#1222)

This commit is contained in:
Steven B.
2024-11-01 18:17:18 +00:00
committed by GitHub
parent 70c96b5a5d
commit 77b654a9aa
5 changed files with 65 additions and 15 deletions

View File

@@ -167,7 +167,7 @@ def get_device_class_from_sys_info(sysinfo: dict[str, Any]) -> type[IotDevice]:
def get_device_class_from_family(
device_type: str, *, https: bool
device_type: str, *, https: bool, require_exact: bool = False
) -> type[Device] | None:
"""Return the device class from the type name."""
supported_device_types: dict[str, type[Device]] = {
@@ -185,8 +185,10 @@ def get_device_class_from_family(
}
lookup_key = f"{device_type}{'.HTTPS' if https else ''}"
if (
cls := supported_device_types.get(lookup_key)
) is None and device_type.startswith("SMART."):
(cls := supported_device_types.get(lookup_key)) is None
and device_type.startswith("SMART.")
and not require_exact
):
_LOGGER.warning("Unknown SMART device with %s, using SmartDevice", device_type)
cls = SmartDevice