Do not error when accessing smart device_type before update (#1319)

This commit is contained in:
Steven B.
2024-12-05 09:14:45 +00:00
committed by GitHub
parent 123ea107b1
commit 4eed945e00
3 changed files with 36 additions and 5 deletions

View File

@@ -765,10 +765,11 @@ class SmartDevice(Device):
if self._device_type is not DeviceType.Unknown:
return self._device_type
# Fallback to device_type (from disco info)
type_str = self._info.get("type", self._info.get("device_type"))
if not type_str: # no update or discovery info
if (
not (type_str := self._info.get("type", self._info.get("device_type")))
or not self._components
):
# no update or discovery info
return self._device_type
self._device_type = self._get_device_type_from_components(