Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Advanced support of Velis Evo WiFi #123

Merged
merged 1 commit into from
Jan 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion ariston/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
Expand Down
23 changes: 20 additions & 3 deletions ariston/ariston_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
ARISTON_DATA_ITEMS,
ARISTON_LITE,
ARISTON_LOGIN,
ARISTON_PLANT_DATA,
ARISTON_PLANTS,
ARISTON_REMOTE,
ARISTON_REPORTS,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
},
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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,
},
Expand Down
21 changes: 19 additions & 2 deletions ariston/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -21,6 +20,7 @@
class PlantData(str, Enum):
"""Plant data enum"""

PD = "plantData"
Med = "medPlantData"
Se = "sePlantData"
Slp = "slpPlantData"
Expand Down Expand Up @@ -193,7 +193,7 @@ class EvoPlantMode(WaterHeaterMode):


@unique
class VelisPlantMode(Enum):
class VelisPlantMode(WaterHeaterMode):
"""Velis plant mode enum"""

MANUAL = 1
Expand Down Expand Up @@ -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"""
Expand Down
126 changes: 126 additions & 0 deletions ariston/evo_one_device.py
Original file line number Diff line number Diff line change
@@ -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