From 1243611854d81fa230a6073f04a1c8fe112376f5 Mon Sep 17 00:00:00 2001 From: "Willem-Jan L. van Rootselaar" Date: Fri, 1 Nov 2024 15:44:53 +0100 Subject: [PATCH 1/2] Add asynchronous method to retrieve temperature unit in BSBLAN class --- src/bsblan/bsblan.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/bsblan/bsblan.py b/src/bsblan/bsblan.py index c4bd46f1..d02d6bd5 100644 --- a/src/bsblan/bsblan.py +++ b/src/bsblan/bsblan.py @@ -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. From 8ca3dc6872f0ab82bbffc1799d73a48429c661cd Mon Sep 17 00:00:00 2001 From: "Willem-Jan L. van Rootselaar" Date: Fri, 1 Nov 2024 15:50:59 +0100 Subject: [PATCH 2/2] Set default temperature unit to Celsius in BSBLAN class --- src/bsblan/bsblan.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bsblan/bsblan.py b/src/bsblan/bsblan.py index d02d6bd5..05aa97fd 100644 --- a/src/bsblan/bsblan.py +++ b/src/bsblan/bsblan.py @@ -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.