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

feat: add support for Ariston Lydos Wifi's boost mode #163

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
22 changes: 17 additions & 5 deletions ariston/__init__.py
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -26,14 +29,15 @@
_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,
WheType.Lux2.value: AristonLux2Device,
WheType.Lux.value: AristonLuxDevice,
}


class Ariston:
"""Ariston class"""

Expand Down Expand Up @@ -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()
Expand All @@ -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)
Expand All @@ -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():
Expand All @@ -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)
Expand Down
39 changes: 39 additions & 0 deletions ariston/lydos_device.py
Original file line number Diff line number Diff line change
@@ -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
Loading