Skip to content

Commit

Permalink
Update central_unit.py
Browse files Browse the repository at this point in the history
  • Loading branch information
jafar-atili authored Jan 12, 2023
1 parent 986dc0b commit c0daff6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/switchbee/api/central_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def _initialize(self, version) -> None:
self.minor = int(match.group(2))
self.revision = int(match.group(3))
self.build = int(match.group(4))

def __repr__(self) -> str:
return f"{self.major}.{self.minor}.{self.revision}.{self.build}"

Expand All @@ -89,6 +89,7 @@ def __init__(
self._aiohttp_session: ClientSession = aiohttp_session

self._mac: str | None = None
self._unique_id: str | None = None
self._version: CUVersion | None = None
self._name: str | None = None
self._last_conf_change: int = 0
Expand Down Expand Up @@ -121,6 +122,10 @@ def version(self) -> CUVersion | None:
def mac(self) -> str | None:
return self._mac

@property
def unique_id(self) -> str | None:
return self._unique_id

@property
def devices(
self,
Expand Down Expand Up @@ -236,7 +241,11 @@ async def fetch_configuration(
self._name = data[ApiAttribute.DATA][ApiAttribute.NAME]
self._version = CUVersion(data[ApiAttribute.DATA][ApiAttribute.VERSION])
self._mac = data[ApiAttribute.DATA][ApiAttribute.MAC]

self._unique_id = (
self._mac
if ApiAttribute.CU_CODE not in data[ApiAttribute.DATA]
else data[ApiAttribute.DATA][ApiAttribute.CU_CODE]
)
if include is None:
return

Expand Down

0 comments on commit c0daff6

Please sign in to comment.