diff --git a/ariston/__init__.py b/ariston/__init__.py index fa2516c..f65d3cf 100644 --- a/ariston/__init__.py +++ b/ariston/__init__.py @@ -1,8 +1,11 @@ """Ariston module""" + import asyncio import logging from typing import Any, Optional +from ariston.lydos_device import AristonLydosDevice + from .ariston_api import AristonAPI, ConnectionException from .const import ( ARISTON_API_URL, @@ -26,7 +29,7 @@ _MAP_WHE_TYPES_TO_CLASS = { WheType.Evo.value: AristonEvoOneDevice, WheType.LydosHybrid.value: AristonLydosHybridDevice, - WheType.Lydos.value: AristonEvoDevice, + WheType.Lydos.value: AristonLydosDevice, WheType.NuosSplit.value: AristonNuosSplitDevice, WheType.Andris2.value: AristonEvoDevice, WheType.Evo2.value: AristonEvoDevice, @@ -34,6 +37,7 @@ WheType.Lux.value: AristonLuxDevice, } + class Ariston: """Ariston class""" @@ -114,7 +118,9 @@ def _get_device( return None -def _connect(username: str, password: str, api_url: str = ARISTON_API_URL) -> AristonAPI: +def _connect( + username: str, password: str, api_url: str = ARISTON_API_URL +) -> AristonAPI: """Connect to ariston api""" api = AristonAPI(username, password, api_url) api.connect() @@ -130,7 +136,9 @@ def _discover(api: AristonAPI) -> list[dict[str, Any]]: return cloud_devices -def discover(username: str, password: str, api_url: str = ARISTON_API_URL) -> list[dict[str, Any]]: +def discover( + username: str, password: str, api_url: str = ARISTON_API_URL +) -> list[dict[str, Any]]: """Retreive ariston devices from the cloud""" api = _connect(username, password, api_url) return _discover(api) @@ -150,7 +158,9 @@ def hello( return _get_device(cloud_devices, api, gateway, is_metric, language_tag) -async def _async_connect(username: str, password: str, api_url: str = ARISTON_API_URL) -> AristonAPI: +async def _async_connect( + username: str, password: str, api_url: str = ARISTON_API_URL +) -> AristonAPI: """Async connect to ariston api""" api = AristonAPI(username, password, api_url) if not await api.async_connect(): @@ -173,7 +183,9 @@ async def _async_discover(api: AristonAPI) -> list[dict[str, Any]]: return cloud_devices -async def async_discover(username: str, password: str, api_url: str = ARISTON_API_URL) -> list[dict[str, Any]]: +async def async_discover( + username: str, password: str, api_url: str = ARISTON_API_URL +) -> list[dict[str, Any]]: """Retreive ariston devices from the cloud""" api = await _async_connect(username, password, api_url) return await _async_discover(api) diff --git a/ariston/lydos_device.py b/ariston/lydos_device.py new file mode 100644 index 0000000..95a8d14 --- /dev/null +++ b/ariston/lydos_device.py @@ -0,0 +1,39 @@ +"""Evo device class for Ariston module.""" + +from __future__ import annotations + +import logging + +from .const import ( + EvoDeviceProperties, + LuxPlantMode, + WaterHeaterMode, +) +from .evo_device import AristonEvoDevice + +_LOGGER = logging.getLogger(__name__) + + +class AristonLydosDevice(AristonEvoDevice): + """Class representing a physical Lydos Wi-Fi device, it's state and properties.""" + + @property + def water_heater_mode(self) -> type[WaterHeaterMode]: + """Return the water heater mode class""" + return LuxPlantMode + + def set_water_heater_operation_mode(self, operation_mode: str): + """Set water heater operation mode""" + self.api.set_evo_mode(self.gw, self.water_heater_mode[operation_mode]) + self.data[EvoDeviceProperties.MODE] = self.water_heater_mode[ + 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, self.water_heater_mode[operation_mode] + ) + self.data[EvoDeviceProperties.MODE] = self.water_heater_mode[ + operation_mode + ].value