diff --git a/ariston/__init__.py b/ariston/__init__.py index 1672184..ba291cf 100644 --- a/ariston/__init__.py +++ b/ariston/__init__.py @@ -14,6 +14,7 @@ from .bsb_device import AristonBsbDevice from .lux_device import AristonLuxDevice from .lux2_device import AristonLux2Device +from .evo_one_device import AristonEvoOneDevice from .evo_device import AristonEvoDevice from .galevo_device import AristonGalevoDevice from .lydos_hybrid_device import AristonLydosHybridDevice @@ -23,7 +24,7 @@ _LOGGER = logging.getLogger(__name__) _MAP_WHE_TYPES_TO_CLASS = { - WheType.Evo.value: AristonEvoDevice, + WheType.Evo.value: AristonEvoOneDevice, WheType.LydosHybrid.value: AristonLydosHybridDevice, WheType.Lydos.value: AristonEvoDevice, WheType.NuosSplit.value: AristonNuosSplitDevice, diff --git a/ariston/ariston_api.py b/ariston/ariston_api.py index 44ce323..6bd3d82 100644 --- a/ariston/ariston_api.py +++ b/ariston/ariston_api.py @@ -16,7 +16,6 @@ ARISTON_DATA_ITEMS, ARISTON_LITE, ARISTON_LOGIN, - ARISTON_PLANT_DATA, ARISTON_PLANTS, ARISTON_REMOTE, ARISTON_REPORTS, @@ -232,6 +231,15 @@ def set_property( }, ) + def set_evo_number_of_showers(self, gw_id: str, number_of_showers: int) -> None: + """Set Velis Evo number of showers""" + self._post( + f"{self.__api_url}{ARISTON_VELIS}/{PlantData.PD.value}/{gw_id}/showers", + { + "new": int(number_of_showers), + }, + ) + def set_evo_mode(self, gw_id: str, value: WaterHeaterMode) -> None: """Set Velis Evo mode""" self._post( @@ -401,7 +409,7 @@ def set_holiday( ) -> None: """Set holidays""" self._post( - f"{self.__api_url}{ARISTON_REMOTE}/{ARISTON_PLANT_DATA}/{gw_id}/holiday", + f"{self.__api_url}{ARISTON_REMOTE}/{PlantData.PD}/{gw_id}/holiday", { "new": holiday_end_date, }, @@ -636,6 +644,15 @@ async def async_set_property( }, ) + async def async_set_evo_number_of_showers(self, gw_id: str, number_of_showers: int) -> None: + """Set Velis Evo number of showers""" + await self._async_post( + f"{self.__api_url}{ARISTON_VELIS}/{PlantData.PD.value}/{gw_id}/showers", + { + "new": int(number_of_showers), + }, + ) + async def async_set_evo_mode(self, gw_id: str, value: WaterHeaterMode) -> None: """Async set Velis Evo mode""" await self._async_post( @@ -813,7 +830,7 @@ async def async_set_holiday( """Async set holidays""" await self._async_post( - f"{self.__api_url}{ARISTON_REMOTE}/{ARISTON_PLANT_DATA}/{gw_id}/holiday", + f"{self.__api_url}{ARISTON_REMOTE}/{PlantData.PD}/{gw_id}/holiday", { "new": holiday_end_date, }, diff --git a/ariston/const.py b/ariston/const.py index 8bd73c9..0ed9d91 100644 --- a/ariston/const.py +++ b/ariston/const.py @@ -11,7 +11,6 @@ ARISTON_DATA_ITEMS: Final[str] = "dataItems" ARISTON_ZONES: Final[str] = "zones" ARISTON_BSB_ZONES: Final[str] = "bsbZones" -ARISTON_PLANT_DATA: Final[str] = "plantData" ARISTON_REPORTS: Final[str] = "reports" ARISTON_TIME_PROGS: Final[str] = "timeProgs" ARISTON_BUS_ERRORS: Final[str] = "busErrors" @@ -21,6 +20,7 @@ class PlantData(str, Enum): """Plant data enum""" + PD = "plantData" Med = "medPlantData" Se = "sePlantData" Slp = "slpPlantData" @@ -193,7 +193,7 @@ class EvoPlantMode(WaterHeaterMode): @unique -class VelisPlantMode(Enum): +class VelisPlantMode(WaterHeaterMode): """Velis plant mode enum""" MANUAL = 1 @@ -372,6 +372,23 @@ class DeviceFeatures: ZONES: Final[str] = "zones" WEATHER_PROVIDER: Final[str] = "weatherProvider" +class EvoOneDeviceProperties: + """Contants for Velis Evo device properties""" + + AV_SHW: Final[str] = "avShw" + ECO: Final[str] = "eco" + GW: Final[str] = "gw" + MAX_AV_SHW: Final[str] = "maxAvShw" + MAX_REQ_SHW: Final[str] = "maxReqShw" + MODE: Final[str] = "mode" + ON: Final[str] = "on" + PROC_REQ_SHW: Final[str] = "procReqShw" + REQ_SHW: Final[str] = "reqShw" + RM_TM: Final[str] = "rmTm" + SHW_P1: Final[str] = "shwP1" + STATE: Final[str] = "state" + TEMP: Final[str] = "temp" + TM_P1: Final[str] = "tmP1" class VelisDeviceProperties: """Contants for Velis device properties""" diff --git a/ariston/evo_one_device.py b/ariston/evo_one_device.py new file mode 100644 index 0000000..20161a8 --- /dev/null +++ b/ariston/evo_one_device.py @@ -0,0 +1,126 @@ +"""Evo device class for Ariston module.""" +from __future__ import annotations + +import logging +from datetime import datetime +from typing import Optional + +from .const import ( + VelisPlantMode, + EvoOneDeviceProperties, + PlantData, + WaterHeaterMode, +) +from .evo_lydos_device import AristonEvoLydosDevice + +_LOGGER = logging.getLogger(__name__) + + +class AristonEvoOneDevice(AristonEvoLydosDevice): + """Class representing a physical device, it's state and properties.""" + + @property + def plant_data(self) -> PlantData: + """Final string to get plant data""" + return PlantData.PD + + @property + def consumption_type(self) -> str: + """String to get consumption type""" + return "Dhw" + + @property + def water_heater_mode(self) -> type[WaterHeaterMode]: + """Return the water heater mode class""" + return VelisPlantMode + + @property + def water_heater_eco_value(self) -> Optional[int]: + """Get water heater eco value""" + return self.data.get(EvoOneDeviceProperties.ECO, None) + + @property + def rm_tm_value(self) -> Optional[str]: + """Get remaining time value""" + return self.data.get(EvoOneDeviceProperties.RM_TM, None) + + @property + def rm_tm_in_minutes(self) -> int: + """Get remaining time value in minutes""" + rm_tm = self.rm_tm_value + if rm_tm is None: + return -1 + time = datetime.strptime(rm_tm, "%H:%M:%S") + return time.hour * 60 + time.minute + + def set_eco_mode(self, eco_mode: bool): + """Set water heater eco_mode""" + self.api.set_evo_eco_mode(self.gw, eco_mode) + self.data[EvoOneDeviceProperties.ECO] = eco_mode + + async def async_set_eco_mode(self, eco_mode: bool): + """Async set water heater eco_mode""" + await self.api.async_set_evo_eco_mode(self.gw, eco_mode) + self.data[EvoOneDeviceProperties.ECO] = eco_mode + + def set_water_heater_operation_mode(self, operation_mode: str): + """Set water heater operation mode""" + self.api.set_evo_mode(self.gw, VelisPlantMode[operation_mode]) + self.data[EvoOneDeviceProperties.MODE] = VelisPlantMode[operation_mode].value + + async def async_set_water_heater_operation_mode(self, operation_mode: str): + """Async set water heater operation mode""" + await self.api.async_set_evo_mode(self.gw, VelisPlantMode[operation_mode]) + self.data[EvoOneDeviceProperties.MODE] = VelisPlantMode[operation_mode].value + + @property + def is_heating(self) -> Optional[bool]: + """Get is the water heater heating""" + return self.data.get(EvoOneDeviceProperties.STATE, None) + + @property + def max_req_shower(self) -> Optional[str]: + """Get maximum requestable shower""" + return self.data.get(EvoOneDeviceProperties.MAX_REQ_SHW, None) + + @property + def req_shower(self) -> Optional[str]: + """Get requested shower""" + return self.data.get(EvoOneDeviceProperties.REQ_SHW, None) + + def set_water_heater_number_of_showers(self, number_of_showers: int): + """Set water heater number of showers""" + self.api.set_evo_number_of_showers(self.gw, number_of_showers) + self.data[EvoOneDeviceProperties.REQ_SHW] = number_of_showers + + async def async_set_water_heater_number_of_showers(self, number_of_showers: int): + """Async set water heater number of showers""" + await self.api.async_set_evo_number_of_showers(self.gw, number_of_showers) + self.data[EvoOneDeviceProperties.REQ_SHW] = number_of_showers + + @property + def water_heater_maximum_temperature(self) -> Optional[float]: + """Get water heater maximum temperature""" + return 0 + + @property + def max_setpoint_temp(self) -> str: + raise NotImplementedError + + @property + def anti_legionella_on_off(self) -> str: + raise NotImplementedError + + @property + def water_heater_maximum_setpoint_temperature_minimum(self) -> Optional[float]: + raise NotImplementedError + + @property + def water_heater_maximum_setpoint_temperature_maximum(self) -> Optional[float]: + raise NotImplementedError + + def set_water_heater_temperature(self, temperature: float) -> None: + raise NotImplementedError + + async def async_set_water_heater_temperature(self, temperature: float) -> None: + raise NotImplementedError