weheat 2025.1.14__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/__init__.py ADDED
@@ -0,0 +1,45 @@
1
+ # coding: utf-8
2
+
3
+ # flake8: noqa
4
+
5
+ """
6
+ Weheat Backend
7
+
8
+ This is the backend for the Weheat project
9
+
10
+ The version of the OpenAPI document: v1
11
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
12
+
13
+ Do not edit the class manually.
14
+ """ # noqa: E501
15
+
16
+
17
+ __version__ = "2024.07.08"
18
+
19
+ # import apis into sdk package
20
+ from weheat.api.energy_log_api import EnergyLogApi
21
+ from weheat.api.heat_pump_api import HeatPumpApi
22
+ from weheat.api.heat_pump_log_api import HeatPumpLogApi
23
+ from weheat.api.user_api import UserApi
24
+
25
+ # import ApiClient
26
+ from weheat.api_response import ApiResponse
27
+ from weheat.api_client import ApiClient
28
+ from weheat.configuration import Configuration
29
+ from weheat.exceptions import OpenApiException
30
+ from weheat.exceptions import ApiTypeError
31
+ from weheat.exceptions import ApiValueError
32
+ from weheat.exceptions import ApiKeyError
33
+ from weheat.exceptions import ApiAttributeError
34
+ from weheat.exceptions import ApiException
35
+
36
+ # import models into sdk package
37
+ from weheat.models.device_state import DeviceState
38
+ from weheat.models.energy_view_dto import EnergyViewDto
39
+ from weheat.models.heat_pump_log_view_dto import HeatPumpLogViewDto
40
+ from weheat.models.raw_heat_pump_log_dto import RawHeatPumpLogDto
41
+ from weheat.models.read_all_heat_pump_dto import ReadAllHeatPumpDto
42
+ from weheat.models.read_heat_pump_dto import ReadHeatPumpDto
43
+ from weheat.models.read_user_dto import ReadUserDto
44
+ from weheat.models.role import Role
45
+
@@ -0,0 +1,3 @@
1
+ from weheat.abstractions.auth import AbstractAuth
2
+ from weheat.abstractions.discovery import HeatPumpDiscovery
3
+ from weheat.abstractions.heat_pump import HeatPump
@@ -0,0 +1,34 @@
1
+ from abc import ABC, abstractmethod
2
+ from aiohttp import ClientSession, ClientResponse
3
+
4
+
5
+ class AbstractAuth(ABC):
6
+ """Abstract class to make authenticated requests."""
7
+
8
+ def __init__(self, websession: ClientSession, host: str) -> None:
9
+ """Initialize the auth."""
10
+ self.websession = websession
11
+ self.host = host
12
+
13
+ @abstractmethod
14
+ async def async_get_access_token(self) -> str:
15
+ """Return a valid access token."""
16
+
17
+ async def request(self, method, url, **kwargs) -> ClientResponse:
18
+ """Make a request."""
19
+ headers = kwargs.get("headers")
20
+
21
+ if headers is None:
22
+ headers = {}
23
+ else:
24
+ headers = dict(headers)
25
+
26
+ access_token = await self.async_get_access_token()
27
+ headers["authorization"] = f"Bearer {access_token}"
28
+
29
+ return await self.websession.request(
30
+ method,
31
+ f"{self.host}/{url}",
32
+ **kwargs,
33
+ headers=headers,
34
+ )
@@ -0,0 +1,62 @@
1
+ import asyncio
2
+ from dataclasses import dataclass
3
+
4
+ from weheat import DeviceState
5
+ from weheat.configuration import Configuration
6
+ from weheat.api_client import ApiClient
7
+ from weheat.api.heat_pump_api import HeatPumpApi
8
+
9
+
10
+ class HeatPumpDiscovery:
11
+ @dataclass
12
+ class HeatPumpInfo:
13
+ uuid: str
14
+ name: str
15
+ model: str
16
+ sn : str
17
+ has_dhw: bool = False
18
+
19
+ @staticmethod
20
+ async def async_discover_active(api_url: str, access_token: str) -> list[HeatPumpInfo]:
21
+ discovered_pumps = []
22
+
23
+ config = Configuration(host=api_url, access_token=access_token)
24
+
25
+ with ApiClient(configuration=config) as client:
26
+
27
+ response = HeatPumpApi(client).api_v1_heat_pumps_get_with_http_info('', 1, 1000, DeviceState.NUMBER_3 ,async_req=True)
28
+
29
+ response = await asyncio.to_thread(response.get)
30
+
31
+ if response.status_code == 200:
32
+ for pump in response.data:
33
+ # Model of the heat pump
34
+ # - BlackBirdP80: BlackBird P80 heat pump (0)
35
+ # - BlackBirdP60: BlackBird P60 heat pump (1)
36
+ # - SparrowP60Brown: Sparrow P60 heat pump, colour brown (default) (2)
37
+ # - SparrowP60Green: Sparrow P60 heat pump, colour green (3)
38
+ # - SparrowP60Grey: Sparrow P60 heat pump, colour grey (4)
39
+ # - FlintP40: Flint P40 heat pump (5)
40
+ model_string = "Blackbird P80 heat pump"
41
+ if pump.model == 1:
42
+ model_string = "Blackbird P60 heat pump"
43
+ elif 2 <= pump.model <= 4:
44
+ model_string = "Sparrow P60 heat pump"
45
+ elif pump.model == 5:
46
+ model_string = "Flint P40 heat pump"
47
+
48
+
49
+ dhw = False
50
+ if pump.dhw_type is not None and pump.dhw_type == 1:
51
+ dhw = True
52
+
53
+ discovered_pumps.append(
54
+ HeatPumpDiscovery.HeatPumpInfo(
55
+ uuid=pump.id,
56
+ name=pump.name,
57
+ model=model_string,
58
+ sn=pump.serial_number,
59
+ has_dhw=dhw,
60
+ )
61
+ )
62
+ return discovered_pumps
@@ -0,0 +1,273 @@
1
+ """Weheat heat pump abstraction from the API."""
2
+ import asyncio
3
+ from enum import Enum, auto
4
+
5
+ from weheat import HeatPumpApi
6
+ from weheat.configuration import Configuration
7
+ from weheat.api_client import ApiClient
8
+ from weheat.api.heat_pump_log_api import HeatPumpLogApi
9
+ from weheat.api.energy_log_api import EnergyLogApi
10
+ from datetime import datetime, timedelta
11
+
12
+ # before this date no energy logs are available, so start from this point onwards
13
+ START_DATE = datetime(2023, 1, 1, 0, 0, 0)
14
+
15
+
16
+ class HeatPump:
17
+ """Heat pump class representing a heat pump."""
18
+ class State(Enum):
19
+ STANDBY = auto()
20
+ WATER_CHECK = auto()
21
+ HEATING = auto()
22
+ COOLING = auto()
23
+ DHW = auto()
24
+ LEGIONELLA_PREVENTION = auto()
25
+ DEFROSTING = auto()
26
+ SELF_TEST = auto()
27
+ MANUAL_CONTROL = auto()
28
+
29
+ def __init__(self, api_url: str, uuid: str) -> None:
30
+ self._api_url = api_url
31
+ self._uuid = uuid
32
+ self._last_log = None
33
+ self._energy_consumption = None
34
+ self._energy_output = None
35
+ self._nominal_max_power = None
36
+
37
+ async def async_get_status(self, access_token: str):
38
+ """Updates the heat pump instance with data from the API."""
39
+ try:
40
+ config = Configuration(host=self._api_url, access_token=access_token)
41
+
42
+ with ApiClient(configuration=config) as client:
43
+ # Set the max power once
44
+ 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
+
49
+ if response.status_code == 200:
50
+ self._set_nominal_max_power_for_model(response.data.model)
51
+
52
+
53
+ response = HeatPumpLogApi(
54
+ client
55
+ ).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)
60
+
61
+ if response.status_code == 200:
62
+ self._last_log = response.data
63
+
64
+ # Also get all energy totals form past years and add them together
65
+ # 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,
67
+ start_time=START_DATE,
68
+ end_time=datetime.now() + timedelta(days=1),
69
+ interval='Month', async_req=True)
70
+
71
+ response = await asyncio.to_thread(response.get)
72
+
73
+ if response.status_code == 200:
74
+ # aggregate the energy consumption
75
+ self._energy_consumption = 0
76
+ self._energy_output = 0
77
+ for year in response.data:
78
+ self._energy_consumption += year.total_ein_cooling
79
+ self._energy_consumption += year.total_ein_heating
80
+ self._energy_consumption += year.total_ein_heating_defrost
81
+ self._energy_consumption += year.total_ein_dhw
82
+ self._energy_consumption += year.total_ein_dhw_defrost
83
+ self._energy_output += year.total_e_out_cooling
84
+ self._energy_output += year.total_e_out_heating
85
+ self._energy_output += year.total_e_out_heating_defrost
86
+ self._energy_output += year.total_e_out_dhw
87
+ self._energy_output += year.total_e_out_dhw_defrost
88
+
89
+
90
+
91
+ except Exception as e:
92
+ self._last_log = None
93
+ self._energy_consumption = None
94
+ raise e
95
+
96
+ def _if_available(self, key):
97
+ """Returns the value from the last logged value if available. None otherwise."""
98
+ if self._last_log is not None and hasattr(self._last_log, key):
99
+ return getattr(self._last_log, key)
100
+ return None
101
+
102
+ def _set_nominal_max_power_for_model(self, model_id:int):
103
+ # These numbers are the rpm at 100% power in the portal
104
+ # RPM can go above 100% if the limit is increased in the portal.
105
+ # except for the Flint, that cannot go above 100%.
106
+ if model_id == 1:
107
+ #BB60
108
+ self._nominal_max_power = 5280
109
+ elif 2 <= model_id <= 4:
110
+ #SP60
111
+ self._nominal_max_power = 5280
112
+ elif model_id == 5:
113
+ # Flint
114
+ self._nominal_max_power = 5400
115
+ else:
116
+ #BB80
117
+ self._nominal_max_power = 4500
118
+
119
+ def __str__(self):
120
+ return f"WeheatHeatPump(uuid={self._uuid}, last update={self._if_available('timestamp')})"
121
+
122
+ def __repr__(self):
123
+ return self.__str__()
124
+
125
+ @property
126
+ def water_inlet_temperature(self):
127
+ """The heat pump water inlet temperature."""
128
+ return self._if_available("t_water_in")
129
+
130
+ @property
131
+ def water_outlet_temperature(self):
132
+ """The heat pump water outlet temperature."""
133
+ return self._if_available("t_water_out")
134
+
135
+ @property
136
+ def water_house_in_temperature(self):
137
+ """The water house in temperature."""
138
+ return self._if_available("t_water_house_in")
139
+
140
+ @property
141
+ def air_inlet_temperature(self):
142
+ """The heat pump air inlet temperature."""
143
+ return self._if_available("t_air_in")
144
+
145
+ @property
146
+ def air_outlet_temperature(self):
147
+ """The heat pump air outlet temperature."""
148
+ return self._if_available("t_air_out")
149
+
150
+ @property
151
+ def thermostat_water_setpoint(self):
152
+ """The thermostat water setpoint."""
153
+ return self._if_available("t_thermostat_setpoint")
154
+
155
+ @property
156
+ def thermostat_room_temperature(self):
157
+ """The thermostat current room temperature."""
158
+ return self._if_available("t_room")
159
+
160
+ @property
161
+ def thermostat_room_temperature_setpoint(self):
162
+ """The thermostat room temperature setpoint."""
163
+ return self._if_available("t_room_target")
164
+
165
+ @property
166
+ def thermostat_on_off_state(self):
167
+ """The thermostat on/off state."""
168
+ return self._if_available("on_off_thermostat_state")
169
+
170
+ @property
171
+ def power_input(self):
172
+ """The heat pumps power input."""
173
+ return self._if_available("cm_mass_power_in")
174
+
175
+ @property
176
+ def power_output(self):
177
+ """The heat pumps hydraulic output power."""
178
+ return self._if_available("cm_mass_power_out")
179
+
180
+ @property
181
+ def dhw_top_temperature(self):
182
+ """The DHW vessel top temperature."""
183
+ return self._if_available("t1")
184
+
185
+ @property
186
+ def dhw_bottom_temperature(self):
187
+ """The DHW vessel bottom temperature."""
188
+ return self._if_available("t2")
189
+
190
+ @property
191
+ def cop(self):
192
+ """
193
+ Returns the coefficient of performance of the heat pump.
194
+ Note that this is calculated from a singular log entry and might not be accurate when the
195
+ heat pump is changing its output power or switching states
196
+ """
197
+ input = self.power_input
198
+ output = self.power_output
199
+ if input is not None and output is not None and input != 0:
200
+ return output / input
201
+
202
+ @property
203
+ def indoor_unit_water_pump_state(self):
204
+ """Decoded water pump state."""
205
+ return self._if_available("control_bridge_status_decoded_water_pump")
206
+
207
+ @property
208
+ def indoor_unit_auxiliary_pump_state(self):
209
+ """Decoded auxiliary pump state."""
210
+ return self._if_available("control_bridge_status_decoded_water_pump2")
211
+
212
+ @property
213
+ def indoor_unit_dhw_valve_or_pump_state(self):
214
+ """Decoded DHW valve or pump state."""
215
+ return self._if_available("control_bridge_status_decoded_dhw_valve")
216
+
217
+ @property
218
+ def indoor_unit_gas_boiler_state(self):
219
+ """Decoded gas boiler state."""
220
+ return self._if_available("control_bridge_status_decoded_gas_boiler")
221
+
222
+ @property
223
+ def indoor_unit_electric_heater_state(self):
224
+ """Decoded electric heater state."""
225
+ return self._if_available("control_bridge_status_decoded_electric_heater")
226
+
227
+ @property
228
+ def compressor_percentage(self):
229
+ current_rpm = self._if_available("rpm")
230
+ if self._nominal_max_power is not None and current_rpm is not None:
231
+ # calculate percentage of rpm
232
+ return int((100 / self._nominal_max_power) * current_rpm)
233
+ return None
234
+
235
+ @property
236
+ def compressor_rpm(self):
237
+ """Compressor RPM."""
238
+ return self._if_available("rpm")
239
+
240
+ @property
241
+ def heat_pump_state(self) -> State | None:
242
+ """The heat pump state."""
243
+ numeric_state = self._if_available("state")
244
+ if numeric_state is None:
245
+ return None
246
+
247
+ if numeric_state == 40:
248
+ return self.State.STANDBY
249
+ elif numeric_state == 70:
250
+ return self.State.HEATING
251
+ elif numeric_state == 130:
252
+ return self.State.COOLING
253
+ elif numeric_state == 150:
254
+ return self.State.DHW
255
+ elif numeric_state == 160:
256
+ return self.State.LEGIONELLA_PREVENTION
257
+ elif numeric_state == 170:
258
+ return self.State.SELF_TEST
259
+ elif numeric_state == 180:
260
+ return self.State.MANUAL_CONTROL
261
+ elif numeric_state >= 200 and numeric_state <= 240:
262
+ return self.State.DEFROSTING
263
+ return None
264
+
265
+ @property
266
+ def energy_total(self):
267
+ """The total used energy in kWh from 2023 to now."""
268
+ return self._energy_consumption
269
+
270
+ @property
271
+ def energy_output(self):
272
+ """The total energy output in kWh from 2023 to now."""
273
+ return self._energy_output
@@ -0,0 +1,23 @@
1
+ import asyncio
2
+
3
+ from weheat.configuration import Configuration
4
+ from weheat.api_client import ApiClient
5
+ from weheat.api.user_api import UserApi
6
+
7
+
8
+ async def async_get_user_id_from_token(api_url: str, access_token: str):
9
+ """ Get the user id from the current logged-in user. """
10
+ try:
11
+ config = Configuration(host=api_url, access_token=access_token)
12
+
13
+ with ApiClient(configuration=config) as client:
14
+ response = UserApi(
15
+ client
16
+ ).api_v1_users_me_get_with_http_info(async_req=True)
17
+
18
+ response = await asyncio.to_thread(response.get)
19
+
20
+ if response.status_code == 200:
21
+ return response.data.id
22
+ except Exception as e:
23
+ raise e
weheat/api/__init__.py ADDED
@@ -0,0 +1,7 @@
1
+ # flake8: noqa
2
+
3
+ # import apis into api package
4
+ from weheat.api.energy_log_api import EnergyLogApi
5
+ from weheat.api.heat_pump_api import HeatPumpApi
6
+ from weheat.api.heat_pump_log_api import HeatPumpLogApi
7
+ from weheat.api.user_api import UserApi
@@ -0,0 +1,230 @@
1
+ # coding: utf-8
2
+
3
+ """
4
+ Weheat Backend
5
+
6
+ This is the backend for the Weheat project
7
+
8
+ The version of the OpenAPI document: v1
9
+ Generated by OpenAPI Generator (https://openapi-generator.tech)
10
+
11
+ Do not edit the class manually.
12
+ """ # noqa: E501
13
+
14
+
15
+ import re # noqa: F401
16
+ import io
17
+ import warnings
18
+
19
+ try:
20
+ from pydantic.v1 import Field, StrictStr, validate_arguments
21
+ except ImportError:
22
+ from pydantic import Field, StrictStr, validate_arguments
23
+
24
+
25
+ from typing_extensions import Annotated
26
+ from datetime import datetime
27
+
28
+ from typing import List, Optional
29
+
30
+ from weheat.models.energy_view_dto import EnergyViewDto
31
+
32
+ from weheat.api_client import ApiClient
33
+ from weheat.api_response import ApiResponse
34
+ from weheat.exceptions import ( # noqa: F401
35
+ ApiTypeError,
36
+ ApiValueError
37
+ )
38
+
39
+
40
+ class EnergyLogApi:
41
+ """NOTE: This class is auto generated by OpenAPI Generator
42
+ Ref: https://openapi-generator.tech
43
+
44
+ Do not edit the class manually.
45
+ """
46
+
47
+ def __init__(self, api_client=None) -> None:
48
+ if api_client is None:
49
+ api_client = ApiClient.get_default()
50
+ self.api_client = api_client
51
+
52
+ @validate_arguments
53
+ def api_v1_energy_logs_heat_pump_id_get(self, heat_pump_id : Annotated[StrictStr, Field(..., description="The id of the heat pump")], start_time : Annotated[Optional[datetime], Field(description="Start time of the interval as a DateTime object in UTC (format: yyyy-MM-dd HH:mm:ss)")] = None, end_time : Annotated[Optional[datetime], Field(description="End time of the interval as a DateTime object in UTC (format: yyyy-MM-dd HH:mm:ss)")] = None, interval : Annotated[Optional[StrictStr], Field(description="Interval granularity of the log data, allowed intervals: \"Hour\", \"Day\", \"Week\", \"Month\", \"Year\"")] = None, x_version : Annotated[Optional[StrictStr], Field(description="Optional version parameter for frontend applications to check if an update / refresh is needed")] = None, **kwargs) -> List[EnergyViewDto]: # noqa: E501
54
+ """Gets the energy logs of the heat pump in a from start time to end time for a given interval Correct Intervals include: Hour, Day, Week, Month, Year Hour logs are rounded to 3 decimals, other logs to 2 decimals # noqa: E501
55
+
56
+ This method makes a synchronous HTTP request by default. To make an
57
+ asynchronous HTTP request, please pass async_req=True
58
+
59
+ >>> thread = api.api_v1_energy_logs_heat_pump_id_get(heat_pump_id, start_time, end_time, interval, x_version, async_req=True)
60
+ >>> result = thread.get()
61
+
62
+ :param heat_pump_id: The id of the heat pump (required)
63
+ :type heat_pump_id: str
64
+ :param start_time: Start time of the interval as a DateTime object in UTC (format: yyyy-MM-dd HH:mm:ss)
65
+ :type start_time: datetime
66
+ :param end_time: End time of the interval as a DateTime object in UTC (format: yyyy-MM-dd HH:mm:ss)
67
+ :type end_time: datetime
68
+ :param interval: Interval granularity of the log data, allowed intervals: \"Hour\", \"Day\", \"Week\", \"Month\", \"Year\"
69
+ :type interval: str
70
+ :param x_version: Optional version parameter for frontend applications to check if an update / refresh is needed
71
+ :type x_version: str
72
+ :param async_req: Whether to execute the request asynchronously.
73
+ :type async_req: bool, optional
74
+ :param _request_timeout: timeout setting for this request.
75
+ If one number provided, it will be total request
76
+ timeout. It can also be a pair (tuple) of
77
+ (connection, read) timeouts.
78
+ :return: Returns the result object.
79
+ If the method is called asynchronously,
80
+ returns the request thread.
81
+ :rtype: List[EnergyViewDto]
82
+ """
83
+ kwargs['_return_http_data_only'] = True
84
+ if '_preload_content' in kwargs:
85
+ message = "Error! Please call the api_v1_energy_logs_heat_pump_id_get_with_http_info method with `_preload_content` instead and obtain raw data from ApiResponse.raw_data" # noqa: E501
86
+ raise ValueError(message)
87
+ return self.api_v1_energy_logs_heat_pump_id_get_with_http_info(heat_pump_id, start_time, end_time, interval, x_version, **kwargs) # noqa: E501
88
+
89
+ @validate_arguments
90
+ def api_v1_energy_logs_heat_pump_id_get_with_http_info(self, heat_pump_id : Annotated[StrictStr, Field(..., description="The id of the heat pump")], start_time : Annotated[Optional[datetime], Field(description="Start time of the interval as a DateTime object in UTC (format: yyyy-MM-dd HH:mm:ss)")] = None, end_time : Annotated[Optional[datetime], Field(description="End time of the interval as a DateTime object in UTC (format: yyyy-MM-dd HH:mm:ss)")] = None, interval : Annotated[Optional[StrictStr], Field(description="Interval granularity of the log data, allowed intervals: \"Hour\", \"Day\", \"Week\", \"Month\", \"Year\"")] = None, x_version : Annotated[Optional[StrictStr], Field(description="Optional version parameter for frontend applications to check if an update / refresh is needed")] = None, **kwargs) -> ApiResponse: # noqa: E501
91
+ """Gets the energy logs of the heat pump in a from start time to end time for a given interval Correct Intervals include: Hour, Day, Week, Month, Year Hour logs are rounded to 3 decimals, other logs to 2 decimals # noqa: E501
92
+
93
+ This method makes a synchronous HTTP request by default. To make an
94
+ asynchronous HTTP request, please pass async_req=True
95
+
96
+ >>> thread = api.api_v1_energy_logs_heat_pump_id_get_with_http_info(heat_pump_id, start_time, end_time, interval, x_version, async_req=True)
97
+ >>> result = thread.get()
98
+
99
+ :param heat_pump_id: The id of the heat pump (required)
100
+ :type heat_pump_id: str
101
+ :param start_time: Start time of the interval as a DateTime object in UTC (format: yyyy-MM-dd HH:mm:ss)
102
+ :type start_time: datetime
103
+ :param end_time: End time of the interval as a DateTime object in UTC (format: yyyy-MM-dd HH:mm:ss)
104
+ :type end_time: datetime
105
+ :param interval: Interval granularity of the log data, allowed intervals: \"Hour\", \"Day\", \"Week\", \"Month\", \"Year\"
106
+ :type interval: str
107
+ :param x_version: Optional version parameter for frontend applications to check if an update / refresh is needed
108
+ :type x_version: str
109
+ :param async_req: Whether to execute the request asynchronously.
110
+ :type async_req: bool, optional
111
+ :param _preload_content: if False, the ApiResponse.data will
112
+ be set to none and raw_data will store the
113
+ HTTP response body without reading/decoding.
114
+ Default is True.
115
+ :type _preload_content: bool, optional
116
+ :param _return_http_data_only: response data instead of ApiResponse
117
+ object with status code, headers, etc
118
+ :type _return_http_data_only: bool, optional
119
+ :param _request_timeout: timeout setting for this request. If one
120
+ number provided, it will be total request
121
+ timeout. It can also be a pair (tuple) of
122
+ (connection, read) timeouts.
123
+ :param _request_auth: set to override the auth_settings for an a single
124
+ request; this effectively ignores the authentication
125
+ in the spec for a single request.
126
+ :type _request_auth: dict, optional
127
+ :type _content_type: string, optional: force content-type for the request
128
+ :return: Returns the result object.
129
+ If the method is called asynchronously,
130
+ returns the request thread.
131
+ :rtype: tuple(List[EnergyViewDto], status_code(int), headers(HTTPHeaderDict))
132
+ """
133
+
134
+ _params = locals()
135
+
136
+ _all_params = [
137
+ 'heat_pump_id',
138
+ 'start_time',
139
+ 'end_time',
140
+ 'interval',
141
+ 'x_version'
142
+ ]
143
+ _all_params.extend(
144
+ [
145
+ 'async_req',
146
+ '_return_http_data_only',
147
+ '_preload_content',
148
+ '_request_timeout',
149
+ '_request_auth',
150
+ '_content_type',
151
+ '_headers'
152
+ ]
153
+ )
154
+
155
+ # validate the arguments
156
+ for _key, _val in _params['kwargs'].items():
157
+ if _key not in _all_params:
158
+ raise ApiTypeError(
159
+ "Got an unexpected keyword argument '%s'"
160
+ " to method api_v1_energy_logs_heat_pump_id_get" % _key
161
+ )
162
+ _params[_key] = _val
163
+ del _params['kwargs']
164
+
165
+ _collection_formats = {}
166
+
167
+ # process the path parameters
168
+ _path_params = {}
169
+ if _params['heat_pump_id'] is not None:
170
+ _path_params['heatPumpId'] = _params['heat_pump_id']
171
+
172
+
173
+ # process the query parameters
174
+ _query_params = []
175
+ if _params.get('start_time') is not None: # noqa: E501
176
+ if isinstance(_params['start_time'], datetime):
177
+ _query_params.append(('startTime', _params['start_time'].strftime(self.api_client.configuration.datetime_format)))
178
+ else:
179
+ _query_params.append(('startTime', _params['start_time']))
180
+
181
+ if _params.get('end_time') is not None: # noqa: E501
182
+ if isinstance(_params['end_time'], datetime):
183
+ _query_params.append(('endTime', _params['end_time'].strftime(self.api_client.configuration.datetime_format)))
184
+ else:
185
+ _query_params.append(('endTime', _params['end_time']))
186
+
187
+ if _params.get('interval') is not None: # noqa: E501
188
+ _query_params.append(('interval', _params['interval']))
189
+
190
+ # process the header parameters
191
+ _header_params = dict(_params.get('_headers', {}))
192
+ if _params['x_version'] is not None:
193
+ _header_params['x-version'] = _params['x_version']
194
+
195
+ # process the form parameters
196
+ _form_params = []
197
+ _files = {}
198
+ # process the body parameter
199
+ _body_params = None
200
+ # set the HTTP header `Accept`
201
+ _header_params['Accept'] = self.api_client.select_header_accept(
202
+ ['text/plain', 'application/json', 'text/json']) # noqa: E501
203
+
204
+ # authentication setting
205
+ _auth_settings = ['oauth2'] # noqa: E501
206
+
207
+ _response_types_map = {
208
+ '403': "str",
209
+ '505': None,
210
+ '200': "List[EnergyViewDto]",
211
+ '400': None,
212
+ '500': None,
213
+ }
214
+
215
+ return self.api_client.call_api(
216
+ '/api/v1/energy-logs/{heatPumpId}', 'GET',
217
+ _path_params,
218
+ _query_params,
219
+ _header_params,
220
+ body=_body_params,
221
+ post_params=_form_params,
222
+ files=_files,
223
+ response_types_map=_response_types_map,
224
+ auth_settings=_auth_settings,
225
+ async_req=_params.get('async_req'),
226
+ _return_http_data_only=_params.get('_return_http_data_only'), # noqa: E501
227
+ _preload_content=_params.get('_preload_content', True),
228
+ _request_timeout=_params.get('_request_timeout'),
229
+ collection_formats=_collection_formats,
230
+ _request_auth=_params.get('_request_auth'))