weheat 2025.1.15rc1__py3-none-any.whl → 2025.1.15rc2__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.
Potentially problematic release.
This version of weheat might be problematic. Click here for more details.
- weheat/abstractions/discovery.py +4 -2
- weheat/abstractions/heat_pump.py +5 -2
- weheat/abstractions/user.py +4 -2
- weheat/configuration.py +10 -1
- weheat/rest.py +27 -19
- {weheat-2025.1.15rc1.dist-info → weheat-2025.1.15rc2.dist-info}/METADATA +1 -1
- {weheat-2025.1.15rc1.dist-info → weheat-2025.1.15rc2.dist-info}/RECORD +10 -10
- {weheat-2025.1.15rc1.dist-info → weheat-2025.1.15rc2.dist-info}/LICENSE +0 -0
- {weheat-2025.1.15rc1.dist-info → weheat-2025.1.15rc2.dist-info}/WHEEL +0 -0
- {weheat-2025.1.15rc1.dist-info → weheat-2025.1.15rc2.dist-info}/top_level.txt +0 -0
weheat/abstractions/discovery.py
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
from dataclasses import dataclass
|
|
3
3
|
|
|
4
|
+
import aiohttp
|
|
5
|
+
|
|
4
6
|
from weheat import DeviceState
|
|
5
7
|
from weheat.configuration import Configuration
|
|
6
8
|
from weheat.api_client import ApiClient
|
|
@@ -17,10 +19,10 @@ class HeatPumpDiscovery:
|
|
|
17
19
|
has_dhw: bool = False
|
|
18
20
|
|
|
19
21
|
@staticmethod
|
|
20
|
-
async def async_discover_active(api_url: str, access_token: str) -> list[HeatPumpInfo]:
|
|
22
|
+
async def async_discover_active(api_url: str, access_token: str, client_session:aiohttp.ClientSession|None = None) -> list[HeatPumpInfo]:
|
|
21
23
|
discovered_pumps = []
|
|
22
24
|
|
|
23
|
-
config = Configuration(host=api_url, access_token=access_token)
|
|
25
|
+
config = Configuration(host=api_url, access_token=access_token, client_session=client_session)
|
|
24
26
|
|
|
25
27
|
async with ApiClient(configuration=config) as client:
|
|
26
28
|
|
weheat/abstractions/heat_pump.py
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
import asyncio
|
|
3
3
|
from enum import Enum, auto
|
|
4
4
|
|
|
5
|
+
import aiohttp
|
|
6
|
+
|
|
5
7
|
from weheat import HeatPumpApi
|
|
6
8
|
from weheat.configuration import Configuration
|
|
7
9
|
from weheat.api_client import ApiClient
|
|
@@ -26,18 +28,19 @@ class HeatPump:
|
|
|
26
28
|
SELF_TEST = auto()
|
|
27
29
|
MANUAL_CONTROL = auto()
|
|
28
30
|
|
|
29
|
-
def __init__(self, api_url: str, uuid: str) -> None:
|
|
31
|
+
def __init__(self, api_url: str, uuid: str, client_session:aiohttp.ClientSession|None = None) -> None:
|
|
30
32
|
self._api_url = api_url
|
|
31
33
|
self._uuid = uuid
|
|
32
34
|
self._last_log = None
|
|
33
35
|
self._energy_consumption = None
|
|
34
36
|
self._energy_output = None
|
|
35
37
|
self._nominal_max_power = None
|
|
38
|
+
self._client = client_session
|
|
36
39
|
|
|
37
40
|
async def async_get_status(self, access_token: str):
|
|
38
41
|
"""Updates the heat pump instance with data from the API."""
|
|
39
42
|
try:
|
|
40
|
-
config = Configuration(host=self._api_url, access_token=access_token)
|
|
43
|
+
config = Configuration(host=self._api_url, access_token=access_token, client_session=self._client)
|
|
41
44
|
|
|
42
45
|
async with ApiClient(configuration=config) as client:
|
|
43
46
|
# Set the max power once
|
weheat/abstractions/user.py
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
|
|
3
|
+
import aiohttp
|
|
4
|
+
|
|
3
5
|
from weheat.configuration import Configuration
|
|
4
6
|
from weheat.api_client import ApiClient
|
|
5
7
|
from weheat.api.user_api import UserApi
|
|
6
8
|
|
|
7
9
|
|
|
8
|
-
async def async_get_user_id_from_token(api_url: str, access_token: str):
|
|
10
|
+
async def async_get_user_id_from_token(api_url: str, access_token: str, client_session:aiohttp.ClientSession|None = None):
|
|
9
11
|
""" Get the user id from the current logged-in user. """
|
|
10
12
|
try:
|
|
11
|
-
config = Configuration(host=api_url, access_token=access_token)
|
|
13
|
+
config = Configuration(host=api_url, access_token=access_token, client_session=client_session)
|
|
12
14
|
|
|
13
15
|
async with ApiClient(configuration=config) as client:
|
|
14
16
|
response = await UserApi(
|
weheat/configuration.py
CHANGED
|
@@ -15,6 +15,8 @@
|
|
|
15
15
|
import copy
|
|
16
16
|
import logging
|
|
17
17
|
import sys
|
|
18
|
+
|
|
19
|
+
import aiohttp
|
|
18
20
|
import urllib3
|
|
19
21
|
|
|
20
22
|
import http.client as httplib
|
|
@@ -51,6 +53,7 @@ class Configuration:
|
|
|
51
53
|
values before.
|
|
52
54
|
:param ssl_ca_cert: str - the path to a file of concatenated CA certificates
|
|
53
55
|
in PEM format.
|
|
56
|
+
: param client_session: A aiohttp.ClientSession to use
|
|
54
57
|
|
|
55
58
|
:Example:
|
|
56
59
|
"""
|
|
@@ -63,7 +66,7 @@ class Configuration:
|
|
|
63
66
|
access_token=None,
|
|
64
67
|
server_index=None, server_variables=None,
|
|
65
68
|
server_operation_index=None, server_operation_variables=None,
|
|
66
|
-
ssl_ca_cert=None,
|
|
69
|
+
ssl_ca_cert=None, client_session=None
|
|
67
70
|
) -> None:
|
|
68
71
|
"""Constructor
|
|
69
72
|
"""
|
|
@@ -179,6 +182,8 @@ class Configuration:
|
|
|
179
182
|
"""date format
|
|
180
183
|
"""
|
|
181
184
|
|
|
185
|
+
self._client_session = client_session
|
|
186
|
+
|
|
182
187
|
def __deepcopy__(self, memo):
|
|
183
188
|
cls = self.__class__
|
|
184
189
|
result = cls.__new__(cls)
|
|
@@ -196,6 +201,10 @@ class Configuration:
|
|
|
196
201
|
def __setattr__(self, name, value):
|
|
197
202
|
object.__setattr__(self, name, value)
|
|
198
203
|
|
|
204
|
+
@property
|
|
205
|
+
def client_session(self) -> aiohttp.ClientSession|None:
|
|
206
|
+
return self._client_session
|
|
207
|
+
|
|
199
208
|
@classmethod
|
|
200
209
|
def set_default(cls, default):
|
|
201
210
|
"""Set default instance of configuration.
|
weheat/rest.py
CHANGED
|
@@ -55,32 +55,37 @@ class RESTClientObject:
|
|
|
55
55
|
# maxsize is number of requests to host that are allowed in parallel
|
|
56
56
|
maxsize = configuration.connection_pool_maxsize
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
configuration.cert_file, keyfile=configuration.key_file
|
|
58
|
+
self._client_session = configuration.client_session
|
|
59
|
+
# only setup SSL when the session is not provided. Otherwise, it will do disk access and HA will get mad.
|
|
60
|
+
if not configuration.client_session:
|
|
61
|
+
ssl_context = ssl.create_default_context(
|
|
62
|
+
cafile=configuration.ssl_ca_cert
|
|
64
63
|
)
|
|
64
|
+
if configuration.cert_file:
|
|
65
|
+
ssl_context.load_cert_chain(
|
|
66
|
+
configuration.cert_file, keyfile=configuration.key_file
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
if not configuration.verify_ssl:
|
|
70
|
+
ssl_context.check_hostname = False
|
|
71
|
+
ssl_context.verify_mode = ssl.CERT_NONE
|
|
65
72
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
73
|
+
connector = aiohttp.TCPConnector(
|
|
74
|
+
limit=maxsize,
|
|
75
|
+
ssl=ssl_context
|
|
76
|
+
)
|
|
69
77
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
78
|
+
# https pool manager
|
|
79
|
+
self.pool_manager = aiohttp.ClientSession(
|
|
80
|
+
connector=connector,
|
|
81
|
+
trust_env=True
|
|
82
|
+
)
|
|
83
|
+
else:
|
|
84
|
+
self.pool_manager = configuration.client_session
|
|
74
85
|
|
|
75
86
|
self.proxy = configuration.proxy
|
|
76
87
|
self.proxy_headers = configuration.proxy_headers
|
|
77
88
|
|
|
78
|
-
# https pool manager
|
|
79
|
-
self.pool_manager = aiohttp.ClientSession(
|
|
80
|
-
connector=connector,
|
|
81
|
-
trust_env=True
|
|
82
|
-
)
|
|
83
|
-
|
|
84
89
|
retries = configuration.retries
|
|
85
90
|
if retries is not None:
|
|
86
91
|
self.retry_client = aiohttp_retry.RetryClient(
|
|
@@ -96,6 +101,9 @@ class RESTClientObject:
|
|
|
96
101
|
self.retry_client = None
|
|
97
102
|
|
|
98
103
|
async def close(self):
|
|
104
|
+
# do not close the session if provided via client_session
|
|
105
|
+
if self._client_session:
|
|
106
|
+
return
|
|
99
107
|
await self.pool_manager.close()
|
|
100
108
|
if self.retry_client is not None:
|
|
101
109
|
await self.retry_client.close()
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
weheat/__init__.py,sha256=C24j_uAbbyEzqh8DmQyORUrVMdFDlzEv4jGClf4TY34,1765
|
|
2
2
|
weheat/api_client.py,sha256=Bh5xHchRGCcsHbT3rXrcmhKCMiumi1_2L6n0Q57KODw,24803
|
|
3
3
|
weheat/api_response.py,sha256=A7O_XgliD6y7jEv82fgIaxR3T8KiwaOqHR6djpZyh_o,674
|
|
4
|
-
weheat/configuration.py,sha256=
|
|
4
|
+
weheat/configuration.py,sha256=8D0zAgx7B6YmVNuyS0AarcCAl5TmKKH655jHqWrvSl0,14531
|
|
5
5
|
weheat/exceptions.py,sha256=jZjLtEMBKFpLTdV1GPsbQSPriG1ilgMSodGnhEKlWh4,5913
|
|
6
6
|
weheat/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
7
|
-
weheat/rest.py,sha256=
|
|
7
|
+
weheat/rest.py,sha256=hSt8T6NQfdrgz_7Dxo9U-DO5ZEgUVVG38OUErThWqlU,7086
|
|
8
8
|
weheat/abstractions/__init__.py,sha256=cRdA_kyTIooo39I13_mqShSfZMqdzNGHbmrnITqgx6A,161
|
|
9
9
|
weheat/abstractions/auth.py,sha256=VCAxJ4OIj7bsYttqJl5-juU0VUlSd3xPu7kUjtHZr3U,979
|
|
10
|
-
weheat/abstractions/discovery.py,sha256=
|
|
11
|
-
weheat/abstractions/heat_pump.py,sha256=
|
|
12
|
-
weheat/abstractions/user.py,sha256=
|
|
10
|
+
weheat/abstractions/discovery.py,sha256=PrhyM29OKvCgKzWig5BAjaEF15CIcTp_AIBZg2lyJ6Y,2384
|
|
11
|
+
weheat/abstractions/heat_pump.py,sha256=DFgKF_4Mdv4dOVugECy9xB4y6e85B-HwZatrUBSnhPE,9920
|
|
12
|
+
weheat/abstractions/user.py,sha256=L48CGvBe7YrUa-wnIgmv9Hu0DOMN4IXN0fSmufrlJIc,760
|
|
13
13
|
weheat/api/__init__.py,sha256=zZ_Xqek8VY6gARsJK6hRess0qqGii-Ls1uXm92k0jPE,244
|
|
14
14
|
weheat/api/energy_log_api.py,sha256=plZ9YoQ9O39qufzr3B6CduuzJMY1K6iJS5f5AXN-vUo,17587
|
|
15
15
|
weheat/api/heat_pump_api.py,sha256=tyFA-Xf-Ld4cAVSYblCq1s5I1CDRQmKJx9UBJivnS0Y,28211
|
|
@@ -30,8 +30,8 @@ weheat/models/read_heat_pump_dto.py,sha256=7jH2MwMVKv_dOoJUUsKE8sTR5mROqco71OzOA
|
|
|
30
30
|
weheat/models/read_user_dto.py,sha256=OIsWQZcdByN94ViSv0DjFHORRsMnkQ93jc-gJuudRdg,4018
|
|
31
31
|
weheat/models/read_user_me_dto.py,sha256=Ger6qKlbZBBvG_4MStl6aEMkrBBJIjQtV6pvK1-lw28,4441
|
|
32
32
|
weheat/models/role.py,sha256=6KUInAmkhoxEdWxBo9jBHXiy_nqJHrKXVeh8RvQPEYM,1101
|
|
33
|
-
weheat-2025.1.
|
|
34
|
-
weheat-2025.1.
|
|
35
|
-
weheat-2025.1.
|
|
36
|
-
weheat-2025.1.
|
|
37
|
-
weheat-2025.1.
|
|
33
|
+
weheat-2025.1.15rc2.dist-info/LICENSE,sha256=rWmFUq0uth2jpet-RQ2QPd2VhZkcPSUs6Dxfmbqkbis,1068
|
|
34
|
+
weheat-2025.1.15rc2.dist-info/METADATA,sha256=lg2CZbj2OGdxFi33MKKI7VrqKmvlBc-Uvf1IIeO3wvA,3877
|
|
35
|
+
weheat-2025.1.15rc2.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
|
36
|
+
weheat-2025.1.15rc2.dist-info/top_level.txt,sha256=hLzdyvGZ9rs4AqK7U48mdHx_-FcP5sDuTSleDUvGAZw,7
|
|
37
|
+
weheat-2025.1.15rc2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|