Skip to content

Commit 829c405

Browse files
committed
Simplify DeviceIdentifier to use __attrs_post_init__ for base_device_url
1 parent bd47a56 commit 829c405

1 file changed

Lines changed: 6 additions & 15 deletions

File tree

pyoverkiz/models.py

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ class Location:
164164
dusk_offset: int = 0
165165

166166

167-
@define(init=False, kw_only=True)
167+
@define(kw_only=True)
168168
class DeviceIdentifier:
169169
"""Parsed components from a device URL."""
170170

@@ -174,20 +174,11 @@ class DeviceIdentifier:
174174
subsystem_id: int | None = None
175175
base_device_url: str = field(repr=obfuscate_id, init=False)
176176

177-
def __init__(
178-
self,
179-
*,
180-
protocol: Protocol,
181-
gateway_id: str,
182-
device_address: str,
183-
subsystem_id: int | None = None,
184-
) -> None:
185-
"""Initialize DeviceIdentifier with required URL components."""
186-
self.protocol = protocol
187-
self.gateway_id = gateway_id
188-
self.device_address = device_address
189-
self.subsystem_id = subsystem_id
190-
self.base_device_url = f"{protocol}://{gateway_id}/{device_address}"
177+
def __attrs_post_init__(self) -> None:
178+
"""Compute base_device_url from protocol, gateway_id and device_address."""
179+
self.base_device_url = (
180+
f"{self.protocol}://{self.gateway_id}/{self.device_address}"
181+
)
191182

192183
@property
193184
def is_sub_device(self) -> bool:

0 commit comments

Comments
 (0)