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

@@ -469,9 +469,11 @@ class Device(ABC):
"""
def __repr__(self):
if self._last_update is None:
return f"<{self.device_type} at {self.host} - update() needed>"
return f"<{self.device_type} at {self.host} - {self.alias} ({self.model})>"
update_needed = " - update() needed" if not self._last_update else ""
return (
f"<{self.device_type} at {self.host} -"
f" {self.alias} ({self.model}){update_needed}>"
)
_deprecated_device_type_attributes = {
# is_type