mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-22 19:23:34 +00:00
Simplify device __repr__ (#805)
Previously: ``` >>> dev <DeviceType.Hub model H100 at 192.168.xx.xx (Smart Hub), is_on: False - dev specific: {'overheated': False, 'signal_level': 2, 'SSID': 'xx'}> >>> dev.children[0] <ChildDevice Temperature Humidity Sensor of <DeviceType.Hub model H100 at 192.168.xx.xx (Smart Hub), is_on: False - dev specific: {'overheated': False, 'signal_level': 2, 'SSID': 'xx'}>> ``` Now: ``` >>> dev Device: <DeviceType.Hub at 192.168.xx.xx - Smart Hub (H100)> >>> dev.children[0] <DeviceType.Sensor Temperature Humidity Sensor (T315) of <DeviceType.Hub at 192.168.xx.xx - Smart Hub (H100)>> ```
This commit is contained in:
parent
fcad0d2344
commit
eb4c048b57
@ -366,8 +366,4 @@ 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} model {self.model} at {self.host}"
|
||||
f" ({self.alias}), is_on: {self.is_on}"
|
||||
f" - dev specific: {self.state_information}>"
|
||||
)
|
||||
return f"<{self.device_type} at {self.host} - {self.alias} ({self.model})>"
|
||||
|
@ -56,4 +56,4 @@ class SmartChildDevice(SmartDevice):
|
||||
return dev_type
|
||||
|
||||
def __repr__(self):
|
||||
return f"<ChildDevice {self.alias} of {self._parent}>"
|
||||
return f"<{self.device_type} {self.alias} ({self.model}) of {self._parent}>"
|
||||
|
@ -198,7 +198,7 @@ async def test_mac(dev):
|
||||
async def test_representation(dev):
|
||||
import re
|
||||
|
||||
pattern = re.compile("<.* model .* at .* (.*), is_on: .* - dev specific: .*>")
|
||||
pattern = re.compile("<DeviceType\..+ at .+? - .*? \(.+?\)>")
|
||||
assert pattern.match(str(dev))
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user