weheat 2024.9.4rc2__tar.gz → 2024.9.10__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.
Potentially problematic release.
This version of weheat might be problematic. Click here for more details.
- {weheat-2024.9.4rc2/weheat.egg-info → weheat-2024.9.10}/PKG-INFO +1 -1
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/pyproject.toml +1 -1
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/setup.py +1 -1
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/abstractions/heat_pump.py +65 -8
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/abstractions/user.py +3 -3
- {weheat-2024.9.4rc2 → weheat-2024.9.10/weheat.egg-info}/PKG-INFO +1 -1
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/LICENSE +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/README.md +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/setup.cfg +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/__init__.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/abstractions/__init__.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/abstractions/auth.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/abstractions/discovery.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/api/__init__.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/api/energy_log_api.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/api/heat_pump_api.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/api/heat_pump_log_api.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/api/user_api.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/api_client.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/api_response.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/configuration.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/exceptions.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/models/__init__.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/models/boiler_type.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/models/device_state.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/models/dhw_type.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/models/energy_view_dto.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/models/heat_pump_log_view_dto.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/models/heat_pump_model.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/models/heat_pump_status_enum.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/models/heat_pump_type.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/models/raw_heat_pump_log_dto.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/models/read_all_heat_pump_dto.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/models/read_heat_pump_dto.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/models/read_user_dto.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/models/role.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/py.typed +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat/rest.py +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat.egg-info/SOURCES.txt +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat.egg-info/dependency_links.txt +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat.egg-info/requires.txt +0 -0
- {weheat-2024.9.4rc2 → weheat-2024.9.10}/weheat.egg-info/top_level.txt +0 -0
|
@@ -21,7 +21,7 @@ from setuptools import setup, find_packages # noqa: H301
|
|
|
21
21
|
# prerequisite: setuptools
|
|
22
22
|
# http://pypi.python.org/pypi/setuptools
|
|
23
23
|
NAME = "weheat"
|
|
24
|
-
VERSION = "2024.09.
|
|
24
|
+
VERSION = "2024.09.10"
|
|
25
25
|
PYTHON_REQUIRES = ">=3.7"
|
|
26
26
|
REQUIRES = [
|
|
27
27
|
"urllib3 >= 1.25.3, < 2.1.0",
|
|
@@ -1,12 +1,18 @@
|
|
|
1
|
+
"""Weheat heat pump abstraction from the API."""
|
|
1
2
|
from enum import Enum, auto
|
|
2
3
|
from weheat.configuration import Configuration
|
|
3
4
|
from weheat.api_client import ApiClient
|
|
4
5
|
from weheat.api.heat_pump_log_api import HeatPumpLogApi
|
|
6
|
+
from weheat.api.energy_log_api import EnergyLogApi
|
|
7
|
+
from datetime import datetime, timedelta
|
|
8
|
+
|
|
9
|
+
# before this date no energy logs are available, so start from this point onwards
|
|
10
|
+
START_DATE = datetime(2023, 1, 1, 0, 0, 0)
|
|
5
11
|
|
|
6
12
|
|
|
7
13
|
class HeatPump:
|
|
14
|
+
"""Heat pump class representing a heat pump."""
|
|
8
15
|
class State(Enum):
|
|
9
|
-
UNDEFINED = auto()
|
|
10
16
|
STANDBY = auto()
|
|
11
17
|
WATER_CHECK = auto()
|
|
12
18
|
HEATING = auto()
|
|
@@ -21,8 +27,10 @@ class HeatPump:
|
|
|
21
27
|
self._api_url = api_url
|
|
22
28
|
self._uuid = uuid
|
|
23
29
|
self._last_log = None
|
|
30
|
+
self._energy_consumption = None
|
|
24
31
|
|
|
25
32
|
def get_status(self, access_token: str):
|
|
33
|
+
"""Updates the heat pump instance with data from the API."""
|
|
26
34
|
try:
|
|
27
35
|
config = Configuration(host=self._api_url, access_token=access_token)
|
|
28
36
|
|
|
@@ -34,14 +42,33 @@ class HeatPump:
|
|
|
34
42
|
)
|
|
35
43
|
if response.status_code == 200:
|
|
36
44
|
self._last_log = response.data
|
|
45
|
+
|
|
46
|
+
# Also get all energy totals form past years and add them together
|
|
47
|
+
# As end time pick today + 1 day to avoid issues with timezones
|
|
48
|
+
response = EnergyLogApi(client).api_v1_energy_logs_heat_pump_id_get_with_http_info(heat_pump_id=self._uuid,
|
|
49
|
+
start_time=START_DATE,
|
|
50
|
+
end_time=datetime.now() + timedelta(days=1),
|
|
51
|
+
interval='Year')
|
|
52
|
+
|
|
53
|
+
if response.status_code == 200:
|
|
54
|
+
# aggregate the energy consumption
|
|
55
|
+
self._energy_consumption = 0
|
|
56
|
+
for year in response.data:
|
|
57
|
+
self._energy_consumption += year.total_ein_cooling
|
|
58
|
+
self._energy_consumption += year.total_ein_heating
|
|
59
|
+
self._energy_consumption += year.total_ein_heating_defrost
|
|
60
|
+
self._energy_consumption += year.total_ein_dhw
|
|
61
|
+
self._energy_consumption += year.total_ein_dhw_defrost
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
|
|
37
65
|
except Exception as e:
|
|
38
66
|
self._last_log = None
|
|
67
|
+
self._energy_consumption = None
|
|
39
68
|
raise e
|
|
40
69
|
|
|
41
|
-
def _update_properties(self):
|
|
42
|
-
pass
|
|
43
|
-
|
|
44
70
|
def _if_available(self, key):
|
|
71
|
+
"""Returns the value from the last logged value if available. None otherwise."""
|
|
45
72
|
if self._last_log is not None and hasattr(self._last_log, key):
|
|
46
73
|
return getattr(self._last_log, key)
|
|
47
74
|
return None
|
|
@@ -54,48 +81,69 @@ class HeatPump:
|
|
|
54
81
|
|
|
55
82
|
@property
|
|
56
83
|
def water_inlet_temperature(self):
|
|
84
|
+
"""The heat pump water inlet temperature."""
|
|
57
85
|
return self._if_available("t_water_in")
|
|
58
86
|
|
|
59
87
|
@property
|
|
60
88
|
def water_outlet_temperature(self):
|
|
89
|
+
"""The heat pump water outlet temperature."""
|
|
61
90
|
return self._if_available("t_water_out")
|
|
62
91
|
|
|
63
92
|
@property
|
|
64
93
|
def water_house_in_temperature(self):
|
|
94
|
+
"""The water house in temperature."""
|
|
65
95
|
return self._if_available("t_water_house_in")
|
|
66
96
|
|
|
67
97
|
@property
|
|
68
98
|
def air_inlet_temperature(self):
|
|
99
|
+
"""The heat pump air inlet temperature."""
|
|
69
100
|
return self._if_available("t_air_in")
|
|
70
101
|
|
|
71
102
|
@property
|
|
72
103
|
def air_outlet_temperature(self):
|
|
104
|
+
"""The heat pump air outlet temperature."""
|
|
73
105
|
return self._if_available("t_air_out")
|
|
74
106
|
|
|
75
107
|
@property
|
|
76
108
|
def thermostat_water_setpoint(self):
|
|
109
|
+
"""The thermostat water setpoint."""
|
|
77
110
|
return self._if_available("t_thermostat_setpoint")
|
|
78
111
|
|
|
79
112
|
@property
|
|
80
113
|
def thermostat_room_temperature(self):
|
|
114
|
+
"""The thermostat current room temperature."""
|
|
81
115
|
return self._if_available("t_room")
|
|
82
116
|
|
|
83
117
|
@property
|
|
84
118
|
def thermostat_room_temperature_setpoint(self):
|
|
119
|
+
"""The thermostat room temperature setpoint."""
|
|
85
120
|
return self._if_available("t_room_target")
|
|
86
121
|
|
|
87
122
|
@property
|
|
88
123
|
def thermostat_on_off_state(self):
|
|
124
|
+
"""The thermostat on/off state."""
|
|
89
125
|
return self._if_available("on_off_thermostat_state")
|
|
90
126
|
|
|
91
127
|
@property
|
|
92
128
|
def power_input(self):
|
|
129
|
+
"""The heat pumps power input."""
|
|
93
130
|
return self._if_available("cm_mass_power_in")
|
|
94
131
|
|
|
95
132
|
@property
|
|
96
133
|
def power_output(self):
|
|
134
|
+
"""The heat pumps hydraulic output power."""
|
|
97
135
|
return self._if_available("cm_mass_power_out")
|
|
98
136
|
|
|
137
|
+
@property
|
|
138
|
+
def dhw_top_temperature(self):
|
|
139
|
+
"""The DHW vessel top temperature."""
|
|
140
|
+
return self._if_available("t1")
|
|
141
|
+
|
|
142
|
+
@property
|
|
143
|
+
def dhw_bottom_temperature(self):
|
|
144
|
+
"""The DHW vessel bottom temperature."""
|
|
145
|
+
return self._if_available("t2")
|
|
146
|
+
|
|
99
147
|
@property
|
|
100
148
|
def cop(self):
|
|
101
149
|
"""
|
|
@@ -110,25 +158,30 @@ class HeatPump:
|
|
|
110
158
|
|
|
111
159
|
@property
|
|
112
160
|
def inside_unit_water_pump_state(self):
|
|
161
|
+
"""Decoded water pump state."""
|
|
113
162
|
return self._if_available("control_bridge_status_decoded_water_pump")
|
|
114
163
|
|
|
115
164
|
@property
|
|
116
165
|
def inside_unit_auxilary_pump_state(self):
|
|
166
|
+
"""Decoded auxilary pump state."""
|
|
117
167
|
return self._if_available("control_bridge_status_decoded_water_pump2")
|
|
118
168
|
|
|
119
169
|
@property
|
|
120
170
|
def inside_unit_dhw_valve_or_pump_state(self):
|
|
171
|
+
"""Decoded DHW valve or pump state."""
|
|
121
172
|
return self._if_available("control_bridge_status_decoded_dhw_valve")
|
|
122
173
|
|
|
123
174
|
@property
|
|
124
175
|
def inside_unit_gas_boiler_state(self):
|
|
176
|
+
"""Decoded gas boiler state."""
|
|
125
177
|
return self._if_available("control_bridge_status_decoded_gas_boiler")
|
|
126
178
|
|
|
127
179
|
@property
|
|
128
|
-
def heat_pump_state(self) -> State:
|
|
180
|
+
def heat_pump_state(self) -> State | None:
|
|
181
|
+
"""The heat pump state."""
|
|
129
182
|
numeric_state = self._if_available("state")
|
|
130
183
|
if numeric_state is None:
|
|
131
|
-
return
|
|
184
|
+
return None
|
|
132
185
|
|
|
133
186
|
if numeric_state == 40:
|
|
134
187
|
return self.State.STANDBY
|
|
@@ -146,5 +199,9 @@ class HeatPump:
|
|
|
146
199
|
return self.State.MANUAL_CONTROL
|
|
147
200
|
elif numeric_state == 200:
|
|
148
201
|
return self.State.DEFROSTING
|
|
149
|
-
|
|
150
|
-
|
|
202
|
+
return None
|
|
203
|
+
|
|
204
|
+
@property
|
|
205
|
+
def energy_total(self):
|
|
206
|
+
"""The total used energy in kWh from 2023 to now."""
|
|
207
|
+
return self._energy_consumption
|
|
@@ -3,7 +3,7 @@ from weheat.api_client import ApiClient
|
|
|
3
3
|
from weheat.api.user_api import UserApi
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
def get_user_id_from_token(api_url: str, access_token: str):
|
|
6
|
+
async def get_user_id_from_token(api_url: str, access_token: str):
|
|
7
7
|
""" Get the user id from the current logged-in user. """
|
|
8
8
|
try:
|
|
9
9
|
config = Configuration(host=api_url, access_token=access_token)
|
|
@@ -11,8 +11,8 @@ def get_user_id_from_token(api_url: str, access_token: str):
|
|
|
11
11
|
with ApiClient(configuration=config) as client:
|
|
12
12
|
response = UserApi(
|
|
13
13
|
client
|
|
14
|
-
).api_v1_users_me_get_with_http_info()
|
|
14
|
+
).api_v1_users_me_get_with_http_info(async_req=True).get()
|
|
15
15
|
if response.status_code == 200:
|
|
16
16
|
return response.data.id
|
|
17
17
|
except Exception as e:
|
|
18
|
-
raise e
|
|
18
|
+
raise e
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|