From 05856ee24e4b0e0b7112eb2161205df80cb5ddc5 Mon Sep 17 00:00:00 2001 From: "Willem-Jan L. van Rootselaar" Date: Fri, 1 Nov 2024 20:02:05 +0100 Subject: [PATCH] Refactor get_temperature_unit method to a property and add debug logging for temperature unit --- src/bsblan/bsblan.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/bsblan/bsblan.py b/src/bsblan/bsblan.py index 05aa97fd..53e21e82 100644 --- a/src/bsblan/bsblan.py +++ b/src/bsblan/bsblan.py @@ -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: