Make __repr__ work on discovery info (#1233)

This PR will make `__repr__` also work on smartdevices where only
discovery data is available by modifying the `model` property to
fallback to the data found in the discovery payloads.
This commit is contained in:
Teemu R.
2024-11-07 20:09:51 +01:00
committed by GitHub
parent 331baf6bc4
commit 4026e8a80c
3 changed files with 32 additions and 4 deletions

View File

@@ -732,8 +732,10 @@ 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"))
self._device_type = self._get_device_type_from_components(
list(self._components.keys()), self._info["type"]
list(self._components.keys()), type_str
)
return self._device_type