weheat 2024.9.5__py3-none-any.whl → 2024.9.10rc1__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.

@@ -2,11 +2,14 @@ from enum import Enum, auto
2
2
  from weheat.configuration import Configuration
3
3
  from weheat.api_client import ApiClient
4
4
  from weheat.api.heat_pump_log_api import HeatPumpLogApi
5
+ from weheat.api.energy_log_api import EnergyLogApi
6
+ from datetime import datetime, timedelta
7
+
8
+ START_DATE = datetime(2024, 1, 11, 0, 0, 0)
5
9
 
6
10
 
7
11
  class HeatPump:
8
12
  class State(Enum):
9
- UNDEFINED = auto()
10
13
  STANDBY = auto()
11
14
  WATER_CHECK = auto()
12
15
  HEATING = auto()
@@ -21,6 +24,7 @@ class HeatPump:
21
24
  self._api_url = api_url
22
25
  self._uuid = uuid
23
26
  self._last_log = None
27
+ self._energy_consumption = None
24
28
 
25
29
  def get_status(self, access_token: str):
26
30
  try:
@@ -34,6 +38,27 @@ class HeatPump:
34
38
  )
35
39
  if response.status_code == 200:
36
40
  self._last_log = response.data
41
+
42
+ # Also get all energy totals form past years and add them together
43
+ # As end time pick today + 1 day to avoid issues with timezones
44
+ response = EnergyLogApi(client).api_v1_energy_logs_heat_pump_id_get_with_http_info(heat_pump_id=self._uuid,
45
+ start_time=START_DATE,
46
+ end_time=datetime.now() + timedelta(days=1),
47
+ interval='Year')
48
+
49
+ if response.status_code == 200:
50
+ # aggregate the energy consumption
51
+ self._energy_consumption = 0
52
+ for year in response.data:
53
+ self._energy_consumption += year.total_ein_cooling
54
+ self._energy_consumption += year.total_ein_heating
55
+ self._energy_consumption += year.total_ein_heating_defrost
56
+ self._energy_consumption += year.total_ein_dhw
57
+ self._energy_consumption += year.total_ein_dhw_defrost
58
+ print(f'Summed for {self._uuid}: {self._energy_consumption}')
59
+
60
+
61
+
37
62
  except Exception as e:
38
63
  self._last_log = None
39
64
  raise e
@@ -133,10 +158,10 @@ class HeatPump:
133
158
  return self._if_available("control_bridge_status_decoded_gas_boiler")
134
159
 
135
160
  @property
136
- def heat_pump_state(self) -> State:
161
+ def heat_pump_state(self) -> State | None:
137
162
  numeric_state = self._if_available("state")
138
163
  if numeric_state is None:
139
- return self.State.UNDEFINED
164
+ return None
140
165
 
141
166
  if numeric_state == 40:
142
167
  return self.State.STANDBY
@@ -154,5 +179,8 @@ class HeatPump:
154
179
  return self.State.MANUAL_CONTROL
155
180
  elif numeric_state == 200:
156
181
  return self.State.DEFROSTING
157
- else:
158
- return self.State.UNDEFINED
182
+ return None
183
+
184
+ @property
185
+ def energy_total(self):
186
+ return self._energy_consumption
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: weheat
3
- Version: 2024.9.5
3
+ Version: 2024.9.10rc1
4
4
  Summary: Weheat Backend client
5
5
  Home-page: https://github.com/wefabricate/wh-python
6
6
  Author: Jesper Raemaekers
@@ -8,7 +8,7 @@ weheat/rest.py,sha256=hLgJ0CYAR1Dr_LppodDNNC_chj5hEQUmzDmbxvID1ao,13808
8
8
  weheat/abstractions/__init__.py,sha256=cRdA_kyTIooo39I13_mqShSfZMqdzNGHbmrnITqgx6A,161
9
9
  weheat/abstractions/auth.py,sha256=VCAxJ4OIj7bsYttqJl5-juU0VUlSd3xPu7kUjtHZr3U,979
10
10
  weheat/abstractions/discovery.py,sha256=0HEXdtIuw3FIATUwX0xpeUVRnk8i-HRL21pE6b1mej0,1679
11
- weheat/abstractions/heat_pump.py,sha256=I4ojfeFtsRrdTkeoD6Z9SMYC7vmlZhezuwdqZNl7qyY,4832
11
+ weheat/abstractions/heat_pump.py,sha256=DiyX9QWEl7PXnm7z2XY1P6ZM0ceFFKsEUBS5uiHZcYM,6303
12
12
  weheat/abstractions/user.py,sha256=n1gmPaLKXmRjF1jDuMQ0951RkbBKm-Cx3cgUU2nOA9U,648
13
13
  weheat/api/__init__.py,sha256=DQnnRs5Z29Nf5sGdFd3f96xM6p_FMym-_-dvQC2VzdU,243
14
14
  weheat/api/energy_log_api.py,sha256=yIIqd-C_xHSM_1eNoj2i04IDkJkzU0-a9iFGDSd2zLo,11374
@@ -29,8 +29,8 @@ weheat/models/read_all_heat_pump_dto.py,sha256=PDaWb-2qSzAnMoIsNceHavT1ybIZa3-lv
29
29
  weheat/models/read_heat_pump_dto.py,sha256=ufDbcHxtB8o2jmk00bMP_xol3uCdoTOqiHS6UUzRic4,4514
30
30
  weheat/models/read_user_dto.py,sha256=J1YlL-WsXArbirllI1fHZrguKy5Wv35NIck59ICBSGg,3465
31
31
  weheat/models/role.py,sha256=eF6nawkz8mmCGQEmJx26Y2MPFmlKdpOOtJ2Q70b-Qtc,938
32
- weheat-2024.9.5.dist-info/LICENSE,sha256=rWmFUq0uth2jpet-RQ2QPd2VhZkcPSUs6Dxfmbqkbis,1068
33
- weheat-2024.9.5.dist-info/METADATA,sha256=TXtxqxQcY3tS-nPmKrdYRVLAEVGvJlT2Ib6UrPBUCJE,3900
34
- weheat-2024.9.5.dist-info/WHEEL,sha256=uCRv0ZEik_232NlR4YDw4Pv3Ajt5bKvMH13NUU7hFuI,91
35
- weheat-2024.9.5.dist-info/top_level.txt,sha256=hLzdyvGZ9rs4AqK7U48mdHx_-FcP5sDuTSleDUvGAZw,7
36
- weheat-2024.9.5.dist-info/RECORD,,
32
+ weheat-2024.9.10rc1.dist-info/LICENSE,sha256=rWmFUq0uth2jpet-RQ2QPd2VhZkcPSUs6Dxfmbqkbis,1068
33
+ weheat-2024.9.10rc1.dist-info/METADATA,sha256=gSAA6RMbmpgA-QqjDhZZV1hC_ZFtM_MovScgEkIQL9E,3904
34
+ weheat-2024.9.10rc1.dist-info/WHEEL,sha256=cVxcB9AmuTcXqmwrtPhNK88dr7IR_b6qagTj0UvIEbY,91
35
+ weheat-2024.9.10rc1.dist-info/top_level.txt,sha256=hLzdyvGZ9rs4AqK7U48mdHx_-FcP5sDuTSleDUvGAZw,7
36
+ weheat-2024.9.10rc1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (74.1.1)
2
+ Generator: setuptools (74.1.2)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5