weheat 2025.1.14rc1__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.

Files changed (36) hide show
  1. weheat/__init__.py +7 -2
  2. weheat/abstractions/discovery.py +6 -6
  3. weheat/abstractions/heat_pump.py +11 -15
  4. weheat/abstractions/user.py +7 -7
  5. weheat/api/__init__.py +1 -0
  6. weheat/api/energy_log_api.py +306 -132
  7. weheat/api/heat_pump_api.py +521 -369
  8. weheat/api/heat_pump_log_api.py +836 -359
  9. weheat/api/user_api.py +243 -115
  10. weheat/api_client.py +234 -261
  11. weheat/api_response.py +10 -18
  12. weheat/configuration.py +14 -9
  13. weheat/exceptions.py +59 -25
  14. weheat/models/__init__.py +6 -0
  15. weheat/models/boiler_type.py +8 -3
  16. weheat/models/device_state.py +9 -4
  17. weheat/models/dhw_type.py +8 -3
  18. weheat/models/energy_view_dto.py +81 -66
  19. weheat/models/heat_pump_log_view_dto.py +527 -481
  20. weheat/models/heat_pump_model.py +8 -3
  21. weheat/models/heat_pump_status_enum.py +8 -3
  22. weheat/models/heat_pump_type.py +8 -3
  23. weheat/models/raw_heat_pump_log_dto.py +353 -315
  24. weheat/models/read_all_heat_pump_dto.py +64 -48
  25. weheat/models/read_heat_pump_dto.py +59 -43
  26. weheat/models/read_user_dto.py +54 -39
  27. weheat/models/read_user_me_dto.py +124 -0
  28. weheat/models/role.py +10 -4
  29. weheat/rest.py +152 -259
  30. weheat-2025.1.15rc2.dist-info/METADATA +115 -0
  31. weheat-2025.1.15rc2.dist-info/RECORD +37 -0
  32. weheat-2025.1.14rc1.dist-info/METADATA +0 -117
  33. weheat-2025.1.14rc1.dist-info/RECORD +0 -36
  34. {weheat-2025.1.14rc1.dist-info → weheat-2025.1.15rc2.dist-info}/LICENSE +0 -0
  35. {weheat-2025.1.14rc1.dist-info → weheat-2025.1.15rc2.dist-info}/WHEEL +0 -0
  36. {weheat-2025.1.14rc1.dist-info → weheat-2025.1.15rc2.dist-info}/top_level.txt +0 -0
weheat/__init__.py CHANGED
@@ -14,7 +14,7 @@
14
14
  """ # noqa: E501
15
15
 
16
16
 
17
- __version__ = "2024.07.08"
17
+ __version__ = "2024.11.15"
18
18
 
19
19
  # import apis into sdk package
20
20
  from weheat.api.energy_log_api import EnergyLogApi
@@ -34,12 +34,17 @@ from weheat.exceptions import ApiAttributeError
34
34
  from weheat.exceptions import ApiException
35
35
 
36
36
  # import models into sdk package
37
+ from weheat.models.boiler_type import BoilerType
37
38
  from weheat.models.device_state import DeviceState
39
+ from weheat.models.dhw_type import DhwType
38
40
  from weheat.models.energy_view_dto import EnergyViewDto
39
41
  from weheat.models.heat_pump_log_view_dto import HeatPumpLogViewDto
42
+ from weheat.models.heat_pump_model import HeatPumpModel
43
+ from weheat.models.heat_pump_status_enum import HeatPumpStatusEnum
44
+ from weheat.models.heat_pump_type import HeatPumpType
40
45
  from weheat.models.raw_heat_pump_log_dto import RawHeatPumpLogDto
41
46
  from weheat.models.read_all_heat_pump_dto import ReadAllHeatPumpDto
42
47
  from weheat.models.read_heat_pump_dto import ReadHeatPumpDto
43
48
  from weheat.models.read_user_dto import ReadUserDto
49
+ from weheat.models.read_user_me_dto import ReadUserMeDto
44
50
  from weheat.models.role import Role
45
-
@@ -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,16 +19,14 @@ 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)
24
-
25
- with ApiClient(configuration=config) as client:
25
+ config = Configuration(host=api_url, access_token=access_token, client_session=client_session)
26
26
 
27
- response = HeatPumpApi(client).api_v1_heat_pumps_get_with_http_info('', 1, 1000, DeviceState.NUMBER_3 ,async_req=True)
27
+ async with ApiClient(configuration=config) as client:
28
28
 
29
- response = await asyncio.to_thread(response.get)
29
+ response = await HeatPumpApi(client).api_v1_heat_pumps_get_with_http_info('', 1, 1000, DeviceState.NUMBER_3)
30
30
 
31
31
  if response.status_code == 200:
32
32
  for pump in response.data:
@@ -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,49 +28,43 @@ 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
- with ApiClient(configuration=config) as client:
45
+ async with ApiClient(configuration=config) as client:
43
46
  # Set the max power once
44
47
  if self._nominal_max_power is None:
45
- response = HeatPumpApi(client).api_v1_heat_pumps_heat_pump_id_get_with_http_info(heat_pump_id=self._uuid, async_req=True)
46
-
47
- response = await asyncio.to_thread(response.get)
48
+ response = await HeatPumpApi(client).api_v1_heat_pumps_heat_pump_id_get_with_http_info(heat_pump_id=self._uuid)
48
49
 
49
50
  if response.status_code == 200:
50
51
  self._set_nominal_max_power_for_model(response.data.model)
51
52
 
52
53
 
53
- response = HeatPumpLogApi(
54
+ response = await HeatPumpLogApi(
54
55
  client
55
56
  ).api_v1_heat_pumps_heat_pump_id_logs_latest_get_with_http_info(
56
- heat_pump_id=self._uuid, async_req=True
57
- )
58
-
59
- response = await asyncio.to_thread(response.get)
57
+ heat_pump_id=self._uuid )
60
58
 
61
59
  if response.status_code == 200:
62
60
  self._last_log = response.data
63
61
 
64
62
  # Also get all energy totals form past years and add them together
65
63
  # As end time pick today + 1 day to avoid issues with timezones
66
- response = EnergyLogApi(client).api_v1_energy_logs_heat_pump_id_get_with_http_info(heat_pump_id=self._uuid,
64
+ response = await EnergyLogApi(client).api_v1_energy_logs_heat_pump_id_get_with_http_info(heat_pump_id=self._uuid,
67
65
  start_time=START_DATE,
68
66
  end_time=datetime.now() + timedelta(days=1),
69
- interval='Month', async_req=True)
70
-
71
- response = await asyncio.to_thread(response.get)
67
+ interval='Month')
72
68
 
73
69
  if response.status_code == 200:
74
70
  # aggregate the energy consumption
@@ -1,21 +1,21 @@
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
- with ApiClient(configuration=config) as client:
14
- response = UserApi(
15
+ async with ApiClient(configuration=config) as client:
16
+ response = await UserApi(
15
17
  client
16
- ).api_v1_users_me_get_with_http_info(async_req=True)
17
-
18
- response = await asyncio.to_thread(response.get)
18
+ ).api_v1_users_me_get_with_http_info()
19
19
 
20
20
  if response.status_code == 200:
21
21
  return response.data.id
weheat/api/__init__.py CHANGED
@@ -5,3 +5,4 @@ from weheat.api.energy_log_api import EnergyLogApi
5
5
  from weheat.api.heat_pump_api import HeatPumpApi
6
6
  from weheat.api.heat_pump_log_api import HeatPumpLogApi
7
7
  from weheat.api.user_api import UserApi
8
+