mirror of
https://github.com/python-kasa/python-kasa.git
synced 2026-10-14 16:44:15 +00:00
Raise UnsupportedDeviceError instead of crashing on unknown device types (#1781)
Use get() instead of index accessor to avoid crashing on unknown devices. --------- Co-authored-by: GhostCoder6969 <ghostcoder6969@gmail.com>
This commit is contained in:
@@ -142,7 +142,13 @@ def get_device_class_from_sys_info(sysinfo: dict[str, Any]) -> type[IotDevice]:
|
||||
# Disabled until properly implemented
|
||||
# DeviceType.Camera: IotCamera,
|
||||
}
|
||||
return TYPE_TO_CLASS[IotDevice._get_device_type_from_sys_info(sysinfo)]
|
||||
device_type = IotDevice._get_device_type_from_sys_info(sysinfo)
|
||||
if (cls := TYPE_TO_CLASS.get(device_type)) is None:
|
||||
raise UnsupportedDeviceError(
|
||||
f"Unsupported device type: {device_type}",
|
||||
discovery_result=sysinfo,
|
||||
)
|
||||
return cls
|
||||
|
||||
|
||||
def get_device_class_from_family(
|
||||
|
||||
Reference in New Issue
Block a user