ariston-net-api 0.20.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ariston_net_api/__init__.py +216 -0
- ariston_net_api/ariston_api.py +992 -0
- ariston_net_api/base_device.py +347 -0
- ariston_net_api/bsb_device.py +447 -0
- ariston_net_api/const.py +651 -0
- ariston_net_api/device.py +60 -0
- ariston_net_api/evo_device.py +113 -0
- ariston_net_api/evo_lydos_device.py +40 -0
- ariston_net_api/evo_one_device.py +109 -0
- ariston_net_api/galevo_device.py +1050 -0
- ariston_net_api/lux2_device.py +24 -0
- ariston_net_api/lux_device.py +42 -0
- ariston_net_api/lydos_device.py +39 -0
- ariston_net_api/lydos_hybrid_device.py +303 -0
- ariston_net_api/nuos_split_device.py +271 -0
- ariston_net_api/velis_base_device.py +105 -0
- ariston_net_api/velis_device.py +132 -0
- ariston_net_api-0.20.0.dist-info/METADATA +163 -0
- ariston_net_api-0.20.0.dist-info/RECORD +21 -0
- ariston_net_api-0.20.0.dist-info/WHEEL +4 -0
- ariston_net_api-0.20.0.dist-info/licenses/LICENSE +22 -0
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
"""Ariston module"""
|
|
2
|
+
|
|
3
|
+
import asyncio
|
|
4
|
+
import logging
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from .ariston_api import AristonAPI, ConnectionException
|
|
8
|
+
from .base_device import AristonBaseDevice
|
|
9
|
+
from .bsb_device import AristonBsbDevice
|
|
10
|
+
from .const import (
|
|
11
|
+
ARISTON_API_URL,
|
|
12
|
+
ARISTON_USER_AGENT,
|
|
13
|
+
DeviceAttribute,
|
|
14
|
+
SystemType,
|
|
15
|
+
VelisDeviceAttribute,
|
|
16
|
+
WheType,
|
|
17
|
+
)
|
|
18
|
+
from .evo_device import AristonEvoDevice
|
|
19
|
+
from .evo_one_device import AristonEvoOneDevice
|
|
20
|
+
from .galevo_device import AristonGalevoDevice
|
|
21
|
+
from .lux2_device import AristonLux2Device
|
|
22
|
+
from .lux_device import AristonLuxDevice
|
|
23
|
+
from .lydos_device import AristonLydosDevice
|
|
24
|
+
from .lydos_hybrid_device import AristonLydosHybridDevice
|
|
25
|
+
from .nuos_split_device import AristonNuosSplitDevice
|
|
26
|
+
from .velis_base_device import AristonVelisBaseDevice
|
|
27
|
+
|
|
28
|
+
_LOGGER = logging.getLogger(__name__)
|
|
29
|
+
|
|
30
|
+
_MAP_WHE_TYPES_TO_CLASS: dict[int, type[AristonVelisBaseDevice]] = {
|
|
31
|
+
WheType.Evo.value: AristonEvoOneDevice,
|
|
32
|
+
WheType.LydosHybrid.value: AristonLydosHybridDevice,
|
|
33
|
+
WheType.Lydos.value: AristonLydosDevice,
|
|
34
|
+
WheType.NuosSplit.value: AristonNuosSplitDevice,
|
|
35
|
+
WheType.Andris2.value: AristonEvoDevice,
|
|
36
|
+
WheType.Evo2.value: AristonEvoDevice,
|
|
37
|
+
WheType.Lux2.value: AristonLux2Device,
|
|
38
|
+
WheType.Lux.value: AristonLuxDevice,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class Ariston:
|
|
43
|
+
"""Ariston class"""
|
|
44
|
+
|
|
45
|
+
def __init__(self) -> None:
|
|
46
|
+
self.api = None
|
|
47
|
+
self.cloud_devices: list[dict[str, Any]] = []
|
|
48
|
+
|
|
49
|
+
async def async_connect(
|
|
50
|
+
self,
|
|
51
|
+
username: str,
|
|
52
|
+
password: str,
|
|
53
|
+
api_url: str = ARISTON_API_URL,
|
|
54
|
+
user_agent: str = ARISTON_USER_AGENT,
|
|
55
|
+
) -> bool:
|
|
56
|
+
"""Connect to the ariston cloud"""
|
|
57
|
+
self.api = AristonAPI(username, password, api_url, user_agent)
|
|
58
|
+
return await self.api.async_connect()
|
|
59
|
+
|
|
60
|
+
async def async_discover(self) -> list[dict[str, Any]]:
|
|
61
|
+
"""Retreive ariston devices from the cloud"""
|
|
62
|
+
if self.api is None:
|
|
63
|
+
_LOGGER.exception("Call async_connect first")
|
|
64
|
+
return []
|
|
65
|
+
cloud_devices = await _async_discover(self.api)
|
|
66
|
+
self.cloud_devices = cloud_devices
|
|
67
|
+
return cloud_devices
|
|
68
|
+
|
|
69
|
+
async def async_hello(
|
|
70
|
+
self, gateway: str, is_metric: bool = True, language_tag: str = "en-US"
|
|
71
|
+
) -> AristonBaseDevice | None:
|
|
72
|
+
"""Get ariston device"""
|
|
73
|
+
if self.api is None:
|
|
74
|
+
_LOGGER.exception("Call async_connect() first")
|
|
75
|
+
return None
|
|
76
|
+
|
|
77
|
+
if len(self.cloud_devices) == 0:
|
|
78
|
+
await self.async_discover()
|
|
79
|
+
|
|
80
|
+
return _get_device(
|
|
81
|
+
self.cloud_devices, self.api, gateway, is_metric, language_tag
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def _get_device(
|
|
86
|
+
cloud_devices: list[dict[str, Any]],
|
|
87
|
+
api: AristonAPI,
|
|
88
|
+
gateway: str,
|
|
89
|
+
is_metric: bool = True,
|
|
90
|
+
language_tag: str = "en-US",
|
|
91
|
+
) -> AristonBaseDevice | None:
|
|
92
|
+
"""Get ariston device"""
|
|
93
|
+
device = next(
|
|
94
|
+
(dev for dev in cloud_devices if dev.get(DeviceAttribute.GW) == gateway),
|
|
95
|
+
None,
|
|
96
|
+
)
|
|
97
|
+
if device is None:
|
|
98
|
+
_LOGGER.exception("No device %s found.", gateway)
|
|
99
|
+
return None
|
|
100
|
+
|
|
101
|
+
system_type = device.get(DeviceAttribute.SYS)
|
|
102
|
+
|
|
103
|
+
match system_type:
|
|
104
|
+
case SystemType.GALEVO.value:
|
|
105
|
+
return AristonGalevoDevice(
|
|
106
|
+
api,
|
|
107
|
+
device,
|
|
108
|
+
is_metric,
|
|
109
|
+
language_tag,
|
|
110
|
+
)
|
|
111
|
+
case SystemType.VELIS.value:
|
|
112
|
+
whe_type = device.get(VelisDeviceAttribute.WHE_TYPE, None)
|
|
113
|
+
device_class = _MAP_WHE_TYPES_TO_CLASS.get(whe_type, None)
|
|
114
|
+
if device_class is None:
|
|
115
|
+
_LOGGER.exception("Unsupported whe type %s", whe_type)
|
|
116
|
+
return None
|
|
117
|
+
return device_class(api, device)
|
|
118
|
+
|
|
119
|
+
case SystemType.BSB.value:
|
|
120
|
+
return AristonBsbDevice(api, device)
|
|
121
|
+
case _:
|
|
122
|
+
_LOGGER.exception("Unsupported system type %s", system_type)
|
|
123
|
+
return None
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def _connect(
|
|
127
|
+
username: str,
|
|
128
|
+
password: str,
|
|
129
|
+
api_url: str = ARISTON_API_URL,
|
|
130
|
+
user_agent: str = ARISTON_USER_AGENT,
|
|
131
|
+
) -> AristonAPI:
|
|
132
|
+
"""Connect to ariston api"""
|
|
133
|
+
api = AristonAPI(username, password, api_url, user_agent)
|
|
134
|
+
api.connect()
|
|
135
|
+
return api
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def _discover(api: AristonAPI) -> list[dict[str, Any]]:
|
|
139
|
+
"""Retreive ariston devices from the cloud"""
|
|
140
|
+
cloud_devices: list[dict[str, Any]] = []
|
|
141
|
+
cloud_devices.extend(api.get_detailed_devices())
|
|
142
|
+
cloud_devices.extend(api.get_detailed_velis_devices())
|
|
143
|
+
|
|
144
|
+
return cloud_devices
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
def discover(
|
|
148
|
+
username: str, password: str, api_url: str = ARISTON_API_URL
|
|
149
|
+
) -> list[dict[str, Any]]:
|
|
150
|
+
"""Retreive ariston devices from the cloud"""
|
|
151
|
+
api = _connect(username, password, api_url)
|
|
152
|
+
return _discover(api)
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def hello(
|
|
156
|
+
username: str,
|
|
157
|
+
password: str,
|
|
158
|
+
gateway: str,
|
|
159
|
+
is_metric: bool = True,
|
|
160
|
+
language_tag: str = "en-US",
|
|
161
|
+
api_url: str = ARISTON_API_URL,
|
|
162
|
+
) -> AristonBaseDevice | None:
|
|
163
|
+
"""Get ariston device"""
|
|
164
|
+
api = _connect(username, password, api_url)
|
|
165
|
+
cloud_devices = _discover(api)
|
|
166
|
+
return _get_device(cloud_devices, api, gateway, is_metric, language_tag)
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
async def _async_connect(
|
|
170
|
+
username: str,
|
|
171
|
+
password: str,
|
|
172
|
+
api_url: str = ARISTON_API_URL,
|
|
173
|
+
user_agent: str = ARISTON_USER_AGENT,
|
|
174
|
+
) -> AristonAPI:
|
|
175
|
+
"""Async connect to ariston api"""
|
|
176
|
+
api = AristonAPI(username, password, api_url, user_agent)
|
|
177
|
+
if not await api.async_connect():
|
|
178
|
+
raise ConnectionException
|
|
179
|
+
return api
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
async def _async_discover(api: AristonAPI) -> list[dict[str, Any]]:
|
|
183
|
+
"""Async retreive ariston devices from the cloud"""
|
|
184
|
+
cloud_devices: list[dict[str, Any]] = []
|
|
185
|
+
cloud_devices_tuple: tuple[
|
|
186
|
+
list[dict[str, Any]], list[dict[str, Any]]
|
|
187
|
+
] = await asyncio.gather(
|
|
188
|
+
api.async_get_detailed_devices(), api.async_get_detailed_velis_devices()
|
|
189
|
+
)
|
|
190
|
+
|
|
191
|
+
for devices in cloud_devices_tuple:
|
|
192
|
+
cloud_devices.extend(devices)
|
|
193
|
+
|
|
194
|
+
return cloud_devices
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
async def async_discover(
|
|
198
|
+
username: str, password: str, api_url: str = ARISTON_API_URL
|
|
199
|
+
) -> list[dict[str, Any]]:
|
|
200
|
+
"""Retreive ariston devices from the cloud"""
|
|
201
|
+
api = await _async_connect(username, password, api_url)
|
|
202
|
+
return await _async_discover(api)
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
async def async_hello(
|
|
206
|
+
username: str,
|
|
207
|
+
password: str,
|
|
208
|
+
gateway: str,
|
|
209
|
+
is_metric: bool = True,
|
|
210
|
+
language_tag: str = "en-US",
|
|
211
|
+
api_url: str = ARISTON_API_URL,
|
|
212
|
+
) -> AristonBaseDevice | None:
|
|
213
|
+
"""Get ariston device"""
|
|
214
|
+
api = await _async_connect(username, password, api_url)
|
|
215
|
+
cloud_devices = await _async_discover(api)
|
|
216
|
+
return _get_device(cloud_devices, api, gateway, is_metric, language_tag)
|