Skip to content

Commit

Permalink
Merge pull request #999 from liudger/add-retrieve-temp-unit
Browse files Browse the repository at this point in the history
Add asynchronous method to retrieve temperature unit in BSBLAN class
  • Loading branch information
liudger authored Nov 1, 2024
2 parents 0b5d383 + 8ca3dc6 commit 3a74558
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/bsblan/bsblan.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class BSBLAN:
_api_data: APIConfig | None = None
_initialized: bool = False
_api_validator: APIValidator = field(init=False)
_temperature_unit: str | None = None
_temperature_unit: str = "°C"

async def __aenter__(self) -> Self:
"""Enter the context manager.
Expand Down Expand Up @@ -223,6 +223,17 @@ async def _initialize_temperature_range(self) -> None:
else:
self._temperature_unit = "°F"

async def get_temperature_unit(self) -> str:
"""Get the unit of temperature.
Returns:
str: The unit of temperature.
"""
if self._temperature_unit is None:
await self._initialize_temperature_range()
return self._temperature_unit

async def _initialize_api_data(self) -> APIConfig:
"""Initialize and cache the API data.
Expand Down

0 comments on commit 3a74558

Please sign in to comment.