ariston-net-api 0.20.0__tar.gz
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-0.20.0/LICENSE +22 -0
- ariston_net_api-0.20.0/PKG-INFO +163 -0
- ariston_net_api-0.20.0/README.md +144 -0
- ariston_net_api-0.20.0/ariston_net_api/__init__.py +216 -0
- ariston_net_api-0.20.0/ariston_net_api/ariston_api.py +992 -0
- ariston_net_api-0.20.0/ariston_net_api/base_device.py +347 -0
- ariston_net_api-0.20.0/ariston_net_api/bsb_device.py +447 -0
- ariston_net_api-0.20.0/ariston_net_api/const.py +651 -0
- ariston_net_api-0.20.0/ariston_net_api/device.py +60 -0
- ariston_net_api-0.20.0/ariston_net_api/evo_device.py +113 -0
- ariston_net_api-0.20.0/ariston_net_api/evo_lydos_device.py +40 -0
- ariston_net_api-0.20.0/ariston_net_api/evo_one_device.py +109 -0
- ariston_net_api-0.20.0/ariston_net_api/galevo_device.py +1050 -0
- ariston_net_api-0.20.0/ariston_net_api/lux2_device.py +24 -0
- ariston_net_api-0.20.0/ariston_net_api/lux_device.py +42 -0
- ariston_net_api-0.20.0/ariston_net_api/lydos_device.py +39 -0
- ariston_net_api-0.20.0/ariston_net_api/lydos_hybrid_device.py +303 -0
- ariston_net_api-0.20.0/ariston_net_api/nuos_split_device.py +271 -0
- ariston_net_api-0.20.0/ariston_net_api/velis_base_device.py +105 -0
- ariston_net_api-0.20.0/ariston_net_api/velis_device.py +132 -0
- ariston_net_api-0.20.0/pyproject.toml +39 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2022 fustom
|
|
4
|
+
Copyright (c) 2026 Wojciech Anioł
|
|
5
|
+
|
|
6
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
in the Software without restriction, including without limitation the rights
|
|
9
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
furnished to do so, subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
SOFTWARE.
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: ariston-net-api
|
|
3
|
+
Version: 0.20.0
|
|
4
|
+
Summary: Ariston module
|
|
5
|
+
Author-email: Tamás Füstös <fustom@gmail.com>
|
|
6
|
+
Maintainer: Wojciech Anioł
|
|
7
|
+
Requires-Python: >=3.13
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: aiohttp
|
|
11
|
+
Requires-Dist: requests
|
|
12
|
+
Requires-Dist: pytest==9.0.3 ; extra == "test"
|
|
13
|
+
Requires-Dist: pytest-asyncio==1.4.0 ; extra == "test"
|
|
14
|
+
Requires-Dist: ruff==0.17.2 ; extra == "test"
|
|
15
|
+
Project-URL: Issues, https://github.com/wojciech-aniol/python-ariston-net-api/issues
|
|
16
|
+
Project-URL: Repository, https://github.com/wojciech-aniol/python-ariston-net-api.git
|
|
17
|
+
Provides-Extra: test
|
|
18
|
+
|
|
19
|
+
[](https://github.com/wojciech-aniol/python-ariston-net-api/actions/workflows/tests.yml)
|
|
20
|
+
|
|
21
|
+
# python-ariston-net-api
|
|
22
|
+
A maintained fork of [fustom/python-ariston-api](https://github.com/fustom/python-ariston-api)
|
|
23
|
+
for the [Ariston NET](https://github.com/wojciech-aniol/ariston-remotethermo-home-assistant-v3)
|
|
24
|
+
Home Assistant integration. The package is `ariston-net-api` and the module is `ariston_net_api`,
|
|
25
|
+
so it can live next to fustom's `ariston` package:
|
|
26
|
+
```python3
|
|
27
|
+
from ariston_net_api import Ariston
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
A Python module for controlling Ariston devices with cloud polling.
|
|
31
|
+
The following devices are currently supported:
|
|
32
|
+
- Ariston Alteas One 24
|
|
33
|
+
- Ariston Velis Evo
|
|
34
|
+
- Ariston Velis Lux
|
|
35
|
+
- Ariston Lydos Hybrid
|
|
36
|
+
- Ariston Genus One
|
|
37
|
+
- Ariston Nuos Split
|
|
38
|
+
- Ariston Thision S
|
|
39
|
+
- Chaffoteaux INOA S 24
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
Use pip3 to install the latest version of this module.
|
|
43
|
+
```
|
|
44
|
+
pip3 install ariston-net-api
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## The easy way (recommended for testing the module)
|
|
48
|
+
First, open Python 3 and import ariston module.
|
|
49
|
+
```
|
|
50
|
+
python3
|
|
51
|
+
```
|
|
52
|
+
```python3
|
|
53
|
+
import ariston_net_api as ariston
|
|
54
|
+
```
|
|
55
|
+
### Syncronous
|
|
56
|
+
Discover devices if you dont know your gateway id. You can skip this step.
|
|
57
|
+
```python3
|
|
58
|
+
raw_devices = ariston.discover("username", "password")
|
|
59
|
+
```
|
|
60
|
+
For example the gateway id for your first device.
|
|
61
|
+
```python3
|
|
62
|
+
raw_devices[0]["gw"]
|
|
63
|
+
```
|
|
64
|
+
Get your device
|
|
65
|
+
```python3
|
|
66
|
+
device = ariston.hello("username", "password", "gateway", is_metric, "location")
|
|
67
|
+
```
|
|
68
|
+
[Go use your device section](#use-your-device)
|
|
69
|
+
### Asyncronous
|
|
70
|
+
```python3
|
|
71
|
+
raw_devices = await ariston.async_discover("username", "password")
|
|
72
|
+
device = await ariston.async_hello(
|
|
73
|
+
"username", "password", "gateway", is_metric, "location"
|
|
74
|
+
)
|
|
75
|
+
```
|
|
76
|
+
[Go use your device section](#use-your-device)
|
|
77
|
+
## The ariston class way (recommended for integrate the module)
|
|
78
|
+
First, open Python 3 and import Ariston class from this module.
|
|
79
|
+
```
|
|
80
|
+
python3
|
|
81
|
+
```
|
|
82
|
+
```python3
|
|
83
|
+
from ariston_net_api import Ariston
|
|
84
|
+
```
|
|
85
|
+
Create a new Ariston instance
|
|
86
|
+
```python3
|
|
87
|
+
ariston = Ariston()
|
|
88
|
+
```
|
|
89
|
+
Now let's try some functions
|
|
90
|
+
|
|
91
|
+
### Connect
|
|
92
|
+
The cloud requests are asynchronous, so if you call them from a synchronous function or not even from function, you should use asyncio.
|
|
93
|
+
```python3
|
|
94
|
+
import asyncio
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Sync
|
|
98
|
+
```python3
|
|
99
|
+
asyncio.run(ariston.async_connect("username", "password"))
|
|
100
|
+
```
|
|
101
|
+
Async
|
|
102
|
+
```python3
|
|
103
|
+
await ariston.async_connect("username", "password")
|
|
104
|
+
```
|
|
105
|
+
- username: Your ariston cloud username.
|
|
106
|
+
- password: Your ariston cloud password.
|
|
107
|
+
|
|
108
|
+
### Discovery
|
|
109
|
+
Use this function to discover devices. You can skip this step if you already know the gateway id.
|
|
110
|
+
|
|
111
|
+
Sync
|
|
112
|
+
```python3
|
|
113
|
+
devices = asyncio.run(ariston.async_discover())
|
|
114
|
+
```
|
|
115
|
+
Async
|
|
116
|
+
```python3
|
|
117
|
+
devices = await ariston.async_discover()
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
## Say hello
|
|
121
|
+
Use this function to create the device object.
|
|
122
|
+
|
|
123
|
+
Sync
|
|
124
|
+
```python3
|
|
125
|
+
device = asyncio.run(ariston.async_hello("gateway", is_metric, "location"))
|
|
126
|
+
```
|
|
127
|
+
Async
|
|
128
|
+
```python3
|
|
129
|
+
device = await ariston.async_hello("gateway", is_metric, "location")
|
|
130
|
+
```
|
|
131
|
+
- gateway: You can find the value in the returned discover dictionary name 'gw'
|
|
132
|
+
- is_metric: Optional. True or False. True means metric, False means imperial. Only works with Galevo (Alteas One, Genus One, etc) system. Default is True.
|
|
133
|
+
- language_tag: Optional. Check https://en.wikipedia.org/wiki/IETF_language_tag Only works with Galevo (Alteas One, Genus One, etc) system. Default is "en-US".
|
|
134
|
+
|
|
135
|
+
## Use your device
|
|
136
|
+
### Get device features
|
|
137
|
+
Sync
|
|
138
|
+
```python3
|
|
139
|
+
device.get_features()
|
|
140
|
+
```
|
|
141
|
+
Async
|
|
142
|
+
```python3
|
|
143
|
+
await device.async_get_features()
|
|
144
|
+
```
|
|
145
|
+
### Get device data
|
|
146
|
+
Sync
|
|
147
|
+
```python3
|
|
148
|
+
device.update_state()
|
|
149
|
+
```
|
|
150
|
+
Async
|
|
151
|
+
```python3
|
|
152
|
+
await device.async_update_state()
|
|
153
|
+
```
|
|
154
|
+
### Get device energy
|
|
155
|
+
Sync
|
|
156
|
+
```python3
|
|
157
|
+
device.update_energy()
|
|
158
|
+
```
|
|
159
|
+
Async
|
|
160
|
+
```python3
|
|
161
|
+
await device.async_update_energy()
|
|
162
|
+
```
|
|
163
|
+
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
[](https://github.com/wojciech-aniol/python-ariston-net-api/actions/workflows/tests.yml)
|
|
2
|
+
|
|
3
|
+
# python-ariston-net-api
|
|
4
|
+
A maintained fork of [fustom/python-ariston-api](https://github.com/fustom/python-ariston-api)
|
|
5
|
+
for the [Ariston NET](https://github.com/wojciech-aniol/ariston-remotethermo-home-assistant-v3)
|
|
6
|
+
Home Assistant integration. The package is `ariston-net-api` and the module is `ariston_net_api`,
|
|
7
|
+
so it can live next to fustom's `ariston` package:
|
|
8
|
+
```python3
|
|
9
|
+
from ariston_net_api import Ariston
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
A Python module for controlling Ariston devices with cloud polling.
|
|
13
|
+
The following devices are currently supported:
|
|
14
|
+
- Ariston Alteas One 24
|
|
15
|
+
- Ariston Velis Evo
|
|
16
|
+
- Ariston Velis Lux
|
|
17
|
+
- Ariston Lydos Hybrid
|
|
18
|
+
- Ariston Genus One
|
|
19
|
+
- Ariston Nuos Split
|
|
20
|
+
- Ariston Thision S
|
|
21
|
+
- Chaffoteaux INOA S 24
|
|
22
|
+
|
|
23
|
+
## Installation
|
|
24
|
+
Use pip3 to install the latest version of this module.
|
|
25
|
+
```
|
|
26
|
+
pip3 install ariston-net-api
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## The easy way (recommended for testing the module)
|
|
30
|
+
First, open Python 3 and import ariston module.
|
|
31
|
+
```
|
|
32
|
+
python3
|
|
33
|
+
```
|
|
34
|
+
```python3
|
|
35
|
+
import ariston_net_api as ariston
|
|
36
|
+
```
|
|
37
|
+
### Syncronous
|
|
38
|
+
Discover devices if you dont know your gateway id. You can skip this step.
|
|
39
|
+
```python3
|
|
40
|
+
raw_devices = ariston.discover("username", "password")
|
|
41
|
+
```
|
|
42
|
+
For example the gateway id for your first device.
|
|
43
|
+
```python3
|
|
44
|
+
raw_devices[0]["gw"]
|
|
45
|
+
```
|
|
46
|
+
Get your device
|
|
47
|
+
```python3
|
|
48
|
+
device = ariston.hello("username", "password", "gateway", is_metric, "location")
|
|
49
|
+
```
|
|
50
|
+
[Go use your device section](#use-your-device)
|
|
51
|
+
### Asyncronous
|
|
52
|
+
```python3
|
|
53
|
+
raw_devices = await ariston.async_discover("username", "password")
|
|
54
|
+
device = await ariston.async_hello(
|
|
55
|
+
"username", "password", "gateway", is_metric, "location"
|
|
56
|
+
)
|
|
57
|
+
```
|
|
58
|
+
[Go use your device section](#use-your-device)
|
|
59
|
+
## The ariston class way (recommended for integrate the module)
|
|
60
|
+
First, open Python 3 and import Ariston class from this module.
|
|
61
|
+
```
|
|
62
|
+
python3
|
|
63
|
+
```
|
|
64
|
+
```python3
|
|
65
|
+
from ariston_net_api import Ariston
|
|
66
|
+
```
|
|
67
|
+
Create a new Ariston instance
|
|
68
|
+
```python3
|
|
69
|
+
ariston = Ariston()
|
|
70
|
+
```
|
|
71
|
+
Now let's try some functions
|
|
72
|
+
|
|
73
|
+
### Connect
|
|
74
|
+
The cloud requests are asynchronous, so if you call them from a synchronous function or not even from function, you should use asyncio.
|
|
75
|
+
```python3
|
|
76
|
+
import asyncio
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Sync
|
|
80
|
+
```python3
|
|
81
|
+
asyncio.run(ariston.async_connect("username", "password"))
|
|
82
|
+
```
|
|
83
|
+
Async
|
|
84
|
+
```python3
|
|
85
|
+
await ariston.async_connect("username", "password")
|
|
86
|
+
```
|
|
87
|
+
- username: Your ariston cloud username.
|
|
88
|
+
- password: Your ariston cloud password.
|
|
89
|
+
|
|
90
|
+
### Discovery
|
|
91
|
+
Use this function to discover devices. You can skip this step if you already know the gateway id.
|
|
92
|
+
|
|
93
|
+
Sync
|
|
94
|
+
```python3
|
|
95
|
+
devices = asyncio.run(ariston.async_discover())
|
|
96
|
+
```
|
|
97
|
+
Async
|
|
98
|
+
```python3
|
|
99
|
+
devices = await ariston.async_discover()
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## Say hello
|
|
103
|
+
Use this function to create the device object.
|
|
104
|
+
|
|
105
|
+
Sync
|
|
106
|
+
```python3
|
|
107
|
+
device = asyncio.run(ariston.async_hello("gateway", is_metric, "location"))
|
|
108
|
+
```
|
|
109
|
+
Async
|
|
110
|
+
```python3
|
|
111
|
+
device = await ariston.async_hello("gateway", is_metric, "location")
|
|
112
|
+
```
|
|
113
|
+
- gateway: You can find the value in the returned discover dictionary name 'gw'
|
|
114
|
+
- is_metric: Optional. True or False. True means metric, False means imperial. Only works with Galevo (Alteas One, Genus One, etc) system. Default is True.
|
|
115
|
+
- language_tag: Optional. Check https://en.wikipedia.org/wiki/IETF_language_tag Only works with Galevo (Alteas One, Genus One, etc) system. Default is "en-US".
|
|
116
|
+
|
|
117
|
+
## Use your device
|
|
118
|
+
### Get device features
|
|
119
|
+
Sync
|
|
120
|
+
```python3
|
|
121
|
+
device.get_features()
|
|
122
|
+
```
|
|
123
|
+
Async
|
|
124
|
+
```python3
|
|
125
|
+
await device.async_get_features()
|
|
126
|
+
```
|
|
127
|
+
### Get device data
|
|
128
|
+
Sync
|
|
129
|
+
```python3
|
|
130
|
+
device.update_state()
|
|
131
|
+
```
|
|
132
|
+
Async
|
|
133
|
+
```python3
|
|
134
|
+
await device.async_update_state()
|
|
135
|
+
```
|
|
136
|
+
### Get device energy
|
|
137
|
+
Sync
|
|
138
|
+
```python3
|
|
139
|
+
device.update_energy()
|
|
140
|
+
```
|
|
141
|
+
Async
|
|
142
|
+
```python3
|
|
143
|
+
await device.async_update_energy()
|
|
144
|
+
```
|
|
@@ -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)
|