From b1e048a417b67bfbdc21c439af6b6721b5702e9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Fri, 26 May 2023 11:09:46 +0200 Subject: [PATCH] thermostat: move to its own file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Álvaro Fernández Rojas --- aioairzone/device.py | 45 +---------------------------------- aioairzone/thermostat.py | 51 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 44 deletions(-) create mode 100644 aioairzone/thermostat.py diff --git a/aioairzone/device.py b/aioairzone/device.py index 21e44d3..b2fa090 100644 --- a/aioairzone/device.py +++ b/aioairzone/device.py @@ -13,7 +13,6 @@ SleepTimeout, SystemType, TemperatureUnit, - ThermostatType, ) from .const import ( API_AIR_DEMAND, @@ -58,9 +57,6 @@ API_SYSTEM_ID, API_SYSTEM_TYPE, API_TEMP_STEP, - API_THERMOS_FIRMWARE, - API_THERMOS_RADIO, - API_THERMOS_TYPE, API_UNITS, API_ZONE_ID, AZD_ABS_TEMP_MAX, @@ -121,10 +117,9 @@ DEFAULT_TEMP_STEP_FAHRENHEIT, ERROR_SYSTEM, ERROR_ZONE, - THERMOSTAT_RADIO, - THERMOSTAT_WIRED, ) from .exceptions import InvalidZone +from .thermostat import Thermostat _LOGGER = logging.getLogger(__name__) @@ -327,44 +322,6 @@ def update_data(self, data: dict[str, Any]) -> None: self.type = SystemType(data[API_SYSTEM_TYPE]) -class Thermostat: - """Airzone Thermostat.""" - - def __init__(self, data: dict[str, Any]): - """Thermostat init.""" - self.firmware: str | None = None - self.radio: bool | None = None - self.type: ThermostatType | None = None - - if API_THERMOS_FIRMWARE in data: - self.firmware = str(data[API_THERMOS_FIRMWARE]) - if API_THERMOS_RADIO in data: - self.radio = bool(data[API_THERMOS_RADIO]) - if API_THERMOS_TYPE in data: - self.type = ThermostatType(data[API_THERMOS_TYPE]) - - def get_firmware(self) -> str | None: - """Return Airzone Thermostat firmware.""" - if self.firmware and "." not in self.firmware and len(self.firmware) > 2: - return f"{self.firmware[0:1]}.{self.firmware[1:]}" - return self.firmware - - def get_model(self) -> str | None: - """Return Airzone Thermostat model.""" - if self.type: - name = str(self.type) - if self.type.exists_radio(): - sfx = f" ({THERMOSTAT_RADIO if self.radio else THERMOSTAT_WIRED})" - else: - sfx = "" - return f"{name}{sfx}" - return None - - def get_radio(self) -> bool | None: - """Return Airzone Thermostat radio.""" - return self.radio - - class Zone: """Airzone Zone.""" diff --git a/aioairzone/thermostat.py b/aioairzone/thermostat.py new file mode 100644 index 0000000..d225bfd --- /dev/null +++ b/aioairzone/thermostat.py @@ -0,0 +1,51 @@ +"""Airzone Local API Thermostat.""" +from __future__ import annotations + +from typing import Any + +from .common import ThermostatType +from .const import ( + API_THERMOS_FIRMWARE, + API_THERMOS_RADIO, + API_THERMOS_TYPE, + THERMOSTAT_RADIO, + THERMOSTAT_WIRED, +) + + +class Thermostat: + """Airzone Thermostat.""" + + def __init__(self, data: dict[str, Any]): + """Thermostat init.""" + self.firmware: str | None = None + self.radio: bool | None = None + self.type: ThermostatType | None = None + + if API_THERMOS_FIRMWARE in data: + self.firmware = str(data[API_THERMOS_FIRMWARE]) + if API_THERMOS_RADIO in data: + self.radio = bool(data[API_THERMOS_RADIO]) + if API_THERMOS_TYPE in data: + self.type = ThermostatType(data[API_THERMOS_TYPE]) + + def get_firmware(self) -> str | None: + """Return Airzone Thermostat firmware.""" + if self.firmware and "." not in self.firmware and len(self.firmware) > 2: + return f"{self.firmware[0:1]}.{self.firmware[1:]}" + return self.firmware + + def get_model(self) -> str | None: + """Return Airzone Thermostat model.""" + if self.type: + name = str(self.type) + if self.type.exists_radio(): + sfx = f" ({THERMOSTAT_RADIO if self.radio else THERMOSTAT_WIRED})" + else: + sfx = "" + return f"{name}{sfx}" + return None + + def get_radio(self) -> bool | None: + """Return Airzone Thermostat radio.""" + return self.radio