Skip to content

Commit

Permalink
Merge pull request #1000 from liudger/add-retrieve-temp-unit
Browse files Browse the repository at this point in the history
Refactor get_temperature_unit method to a property
  • Loading branch information
liudger authored Nov 1, 2024
2 parents 3a74558 + 05856ee commit 24f915e
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/bsblan/bsblan.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,16 +222,20 @@ async def _initialize_temperature_range(self) -> None:
self._temperature_unit = "°C"
else:
self._temperature_unit = "°F"
logger.debug("Temperature unit: %s", self._temperature_unit)

async def get_temperature_unit(self) -> str:
@property
def get_temperature_unit(self) -> str:
"""Get the unit of temperature.
Returns:
str: The unit of temperature.
str: The unit of temperature (°C or °F).
Note:
This property assumes the client has been initialized. If accessed before
initialization, it will return the default unit (°C).
"""
if self._temperature_unit is None:
await self._initialize_temperature_range()
return self._temperature_unit

async def _initialize_api_data(self) -> APIConfig:
Expand Down

0 comments on commit 24f915e

Please sign in to comment.