Skip to content

Commit b7af9b3

Browse files
authored
Refactor. Code cleanup. Small fixes. (#170)
1 parent 49bb1be commit b7af9b3

File tree

5 files changed

+390
-221
lines changed

5 files changed

+390
-221
lines changed

ariston/__init__.py

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""Ariston module"""
2+
23
import asyncio
34
import logging
4-
from typing import Any, Optional
5+
from typing import Any, Optional, Type
56

67
from .ariston_api import AristonAPI, ConnectionException
78
from .const import (
@@ -21,10 +22,11 @@
2122
from .lydos_hybrid_device import AristonLydosHybridDevice
2223
from .nuos_split_device import AristonNuosSplitDevice
2324
from .base_device import AristonBaseDevice
25+
from .velis_base_device import AristonVelisBaseDevice
2426

2527
_LOGGER = logging.getLogger(__name__)
2628

27-
_MAP_WHE_TYPES_TO_CLASS = {
29+
_MAP_WHE_TYPES_TO_CLASS: dict[int, Type[AristonVelisBaseDevice]] = {
2830
WheType.Evo.value: AristonEvoOneDevice,
2931
WheType.LydosHybrid.value: AristonLydosHybridDevice,
3032
WheType.Lydos.value: AristonEvoDevice,
@@ -43,7 +45,11 @@ def __init__(self) -> None:
4345
self.cloud_devices: list[dict[str, Any]] = []
4446

4547
async def async_connect(
46-
self, username: str, password: str, api_url: str = ARISTON_API_URL, user_agent: str = ARISTON_USER_AGENT
48+
self,
49+
username: str,
50+
password: str,
51+
api_url: str = ARISTON_API_URL,
52+
user_agent: str = ARISTON_USER_AGENT,
4753
) -> bool:
4854
"""Connect to the ariston cloud"""
4955
self.api = AristonAPI(username, password, api_url, user_agent)
@@ -115,7 +121,12 @@ def _get_device(
115121
return None
116122

117123

118-
def _connect(username: str, password: str, api_url: str = ARISTON_API_URL, user_agent: str = ARISTON_USER_AGENT) -> AristonAPI:
124+
def _connect(
125+
username: str,
126+
password: str,
127+
api_url: str = ARISTON_API_URL,
128+
user_agent: str = ARISTON_USER_AGENT,
129+
) -> AristonAPI:
119130
"""Connect to ariston api"""
120131
api = AristonAPI(username, password, api_url, user_agent)
121132
api.connect()
@@ -131,7 +142,9 @@ def _discover(api: AristonAPI) -> list[dict[str, Any]]:
131142
return cloud_devices
132143

133144

134-
def discover(username: str, password: str, api_url: str = ARISTON_API_URL) -> list[dict[str, Any]]:
145+
def discover(
146+
username: str, password: str, api_url: str = ARISTON_API_URL
147+
) -> list[dict[str, Any]]:
135148
"""Retreive ariston devices from the cloud"""
136149
api = _connect(username, password, api_url)
137150
return _discover(api)
@@ -151,7 +164,12 @@ def hello(
151164
return _get_device(cloud_devices, api, gateway, is_metric, language_tag)
152165

153166

154-
async def _async_connect(username: str, password: str, api_url: str = ARISTON_API_URL, user_agent: str = ARISTON_USER_AGENT) -> AristonAPI:
167+
async def _async_connect(
168+
username: str,
169+
password: str,
170+
api_url: str = ARISTON_API_URL,
171+
user_agent: str = ARISTON_USER_AGENT,
172+
) -> AristonAPI:
155173
"""Async connect to ariston api"""
156174
api = AristonAPI(username, password, api_url, user_agent)
157175
if not await api.async_connect():
@@ -174,7 +192,9 @@ async def _async_discover(api: AristonAPI) -> list[dict[str, Any]]:
174192
return cloud_devices
175193

176194

177-
async def async_discover(username: str, password: str, api_url: str = ARISTON_API_URL) -> list[dict[str, Any]]:
195+
async def async_discover(
196+
username: str, password: str, api_url: str = ARISTON_API_URL
197+
) -> list[dict[str, Any]]:
178198
"""Retreive ariston devices from the cloud"""
179199
api = await _async_connect(username, password, api_url)
180200
return await _async_discover(api)

0 commit comments

Comments
 (0)