Skip to content

Commit 251e3d7

Browse files
committed
- Add hostname property to Device class
- Mark dataclasses as frozen
1 parent a7ba734 commit 251e3d7

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

busytag.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,22 +31,22 @@ class LedPin(IntFlag):
3131
ALL = 127
3232

3333

34-
@dataclass
34+
@dataclass(frozen=True)
3535
class FileEntry:
3636
"""File stored in the Busy Tag device."""
3737
name: str
3838
size: int
3939
type: FileEntryType = FileEntryType.FILE
4040

4141

42-
@dataclass
42+
@dataclass(frozen=True)
4343
class WifiConfig:
4444
"""Wifi configuration."""
4545
ssid: str
4646
password: str
4747

4848

49-
@dataclass
49+
@dataclass(frozen=True)
5050
class LedConfig:
5151
pins: LedPin
5252
color: str
@@ -55,7 +55,7 @@ def __post_init__(self):
5555
assert rgb_re.match(self.color)
5656

5757

58-
@dataclass
58+
@dataclass(frozen=True)
5959
class LedPatternEntry:
6060
pins: LedPin
6161
color: str
@@ -67,7 +67,7 @@ def __post_init__(self):
6767
assert self.speed >= 0
6868
assert self.delay >= 0
6969

70-
def __str__(self):
70+
def __str__(self) -> str:
7171
return f'{int(self.pins)},{self.color},{self.speed},{self.delay}'
7272

7373

@@ -122,6 +122,7 @@ def __init__(self, port_path: Optional[str] = None,
122122
self.__capacity = int(self.__get_readonly_attribute('TSS'))
123123
self.__device_id = self.__get_readonly_attribute('ID')
124124
self.__firmware_version = self.__get_readonly_attribute('FV')
125+
self.__hostname = self.__get_readonly_attribute('LHA').removeprefix('http://')
125126
self.__manufacturer = self.__get_readonly_attribute('MN')
126127
self.__name = self.__get_readonly_attribute('DN')
127128

@@ -274,6 +275,10 @@ def capacity(self) -> int:
274275
def device_id(self) -> str:
275276
return self.__device_id
276277

278+
@property
279+
def hostname(self) -> str:
280+
return self.__hostname
281+
277282
@property
278283
def firmware_version(self) -> str:
279284
return self.__firmware_version

0 commit comments

Comments
 (0)