weheat 2025.1.14__py3-none-any.whl → 2025.1.15__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/api_response.py CHANGED
@@ -1,29 +1,21 @@
1
1
  """API response object."""
2
2
 
3
3
  from __future__ import annotations
4
- from typing import Any, Dict, Optional
4
+ from typing import Any, Dict, Optional, Generic, TypeVar
5
+ from pydantic import Field, StrictInt, StrictStr, StrictBytes, BaseModel
5
6
 
6
- try:
7
- from pydantic.v1 import Field, StrictInt, StrictStr
8
- except ImportError:
9
- from pydantic import Field, StrictInt, StrictStr
7
+ T = TypeVar("T")
10
8
 
11
- class ApiResponse:
9
+ class ApiResponse(BaseModel, Generic[T]):
12
10
  """
13
11
  API response object
14
12
  """
15
13
 
16
- status_code: Optional[StrictInt] = Field(None, description="HTTP status code")
14
+ status_code: StrictInt = Field(description="HTTP status code")
17
15
  headers: Optional[Dict[StrictStr, StrictStr]] = Field(None, description="HTTP headers")
18
- data: Optional[Any] = Field(None, description="Deserialized data given the data type")
19
- raw_data: Optional[Any] = Field(None, description="Raw data (HTTP response body)")
16
+ data: T = Field(description="Deserialized data given the data type")
17
+ raw_data: StrictBytes = Field(description="Raw data (HTTP response body)")
20
18
 
21
- def __init__(self,
22
- status_code=None,
23
- headers=None,
24
- data=None,
25
- raw_data=None) -> None:
26
- self.status_code = status_code
27
- self.headers = headers
28
- self.data = data
29
- self.raw_data = raw_data
19
+ model_config = {
20
+ "arbitrary_types_allowed": True
21
+ }
weheat/configuration.py CHANGED
@@ -14,8 +14,9 @@
14
14
 
15
15
  import copy
16
16
  import logging
17
- import multiprocessing
18
17
  import sys
18
+
19
+ import aiohttp
19
20
  import urllib3
20
21
 
21
22
  import http.client as httplib
@@ -52,6 +53,7 @@ class Configuration:
52
53
  values before.
53
54
  :param ssl_ca_cert: str - the path to a file of concatenated CA certificates
54
55
  in PEM format.
56
+ : param client_session: A aiohttp.ClientSession to use
55
57
 
56
58
  :Example:
57
59
  """
@@ -64,7 +66,7 @@ class Configuration:
64
66
  access_token=None,
65
67
  server_index=None, server_variables=None,
66
68
  server_operation_index=None, server_operation_variables=None,
67
- ssl_ca_cert=None,
69
+ ssl_ca_cert=None, client_session=None
68
70
  ) -> None:
69
71
  """Constructor
70
72
  """
@@ -148,12 +150,9 @@ class Configuration:
148
150
  Set this to the SNI value expected by the server.
149
151
  """
150
152
 
151
- self.connection_pool_maxsize = multiprocessing.cpu_count() * 5
152
- """urllib3 connection pool's maximum number of connections saved
153
- per pool. urllib3 uses 1 connection as default value, but this is
154
- not the best value when you are making a lot of possibly parallel
155
- requests to the same host, which is often the case here.
156
- cpu_count * 5 is used as default value to increase performance.
153
+ self.connection_pool_maxsize = 100
154
+ """This value is passed to the aiohttp to limit simultaneous connections.
155
+ Default values is 100, None means no-limit.
157
156
  """
158
157
 
159
158
  self.proxy = None
@@ -183,6 +182,8 @@ class Configuration:
183
182
  """date format
184
183
  """
185
184
 
185
+ self._client_session = client_session
186
+
186
187
  def __deepcopy__(self, memo):
187
188
  cls = self.__class__
188
189
  result = cls.__new__(cls)
@@ -200,6 +201,10 @@ class Configuration:
200
201
  def __setattr__(self, name, value):
201
202
  object.__setattr__(self, name, value)
202
203
 
204
+ @property
205
+ def client_session(self) -> aiohttp.ClientSession|None:
206
+ return self._client_session
207
+
203
208
  @classmethod
204
209
  def set_default(cls, default):
205
210
  """Set default instance of configuration.
@@ -376,7 +381,7 @@ class Configuration:
376
381
  "OS: {env}\n"\
377
382
  "Python Version: {pyversion}\n"\
378
383
  "Version of the API: v1\n"\
379
- "SDK Package Version: 2024.07.08".\
384
+ "SDK Package Version: 2024.11.15".\
380
385
  format(env=sys.platform, pyversion=sys.version)
381
386
 
382
387
  def get_host_settings(self):
weheat/exceptions.py CHANGED
@@ -11,6 +11,9 @@
11
11
  Do not edit the class manually.
12
12
  """ # noqa: E501
13
13
 
14
+ from typing import Any, Optional
15
+
16
+ from typing_extensions import Self
14
17
 
15
18
  class OpenApiException(Exception):
16
19
  """The base exception class for all OpenAPIExceptions"""
@@ -101,17 +104,56 @@ class ApiKeyError(OpenApiException, KeyError):
101
104
 
102
105
  class ApiException(OpenApiException):
103
106
 
104
- def __init__(self, status=None, reason=None, http_resp=None) -> None:
107
+ def __init__(
108
+ self,
109
+ status=None,
110
+ reason=None,
111
+ http_resp=None,
112
+ *,
113
+ body: Optional[str] = None,
114
+ data: Optional[Any] = None,
115
+ ) -> None:
116
+ self.status = status
117
+ self.reason = reason
118
+ self.body = body
119
+ self.data = data
120
+ self.headers = None
121
+
105
122
  if http_resp:
106
- self.status = http_resp.status
107
- self.reason = http_resp.reason
108
- self.body = http_resp.data
123
+ if self.status is None:
124
+ self.status = http_resp.status
125
+ if self.reason is None:
126
+ self.reason = http_resp.reason
127
+ if self.body is None:
128
+ try:
129
+ self.body = http_resp.data.decode('utf-8')
130
+ except Exception:
131
+ pass
109
132
  self.headers = http_resp.getheaders()
110
- else:
111
- self.status = status
112
- self.reason = reason
113
- self.body = None
114
- self.headers = None
133
+
134
+ @classmethod
135
+ def from_response(
136
+ cls,
137
+ *,
138
+ http_resp,
139
+ body: Optional[str],
140
+ data: Optional[Any],
141
+ ) -> Self:
142
+ if http_resp.status == 400:
143
+ raise BadRequestException(http_resp=http_resp, body=body, data=data)
144
+
145
+ if http_resp.status == 401:
146
+ raise UnauthorizedException(http_resp=http_resp, body=body, data=data)
147
+
148
+ if http_resp.status == 403:
149
+ raise ForbiddenException(http_resp=http_resp, body=body, data=data)
150
+
151
+ if http_resp.status == 404:
152
+ raise NotFoundException(http_resp=http_resp, body=body, data=data)
153
+
154
+ if 500 <= http_resp.status <= 599:
155
+ raise ServiceException(http_resp=http_resp, body=body, data=data)
156
+ raise ApiException(http_resp=http_resp, body=body, data=data)
115
157
 
116
158
  def __str__(self):
117
159
  """Custom error messages for exception"""
@@ -121,38 +163,30 @@ class ApiException(OpenApiException):
121
163
  error_message += "HTTP response headers: {0}\n".format(
122
164
  self.headers)
123
165
 
124
- if self.body:
125
- error_message += "HTTP response body: {0}\n".format(self.body)
166
+ if self.data or self.body:
167
+ error_message += "HTTP response body: {0}\n".format(self.data or self.body)
126
168
 
127
169
  return error_message
128
170
 
171
+
129
172
  class BadRequestException(ApiException):
173
+ pass
130
174
 
131
- def __init__(self, status=None, reason=None, http_resp=None) -> None:
132
- super(BadRequestException, self).__init__(status, reason, http_resp)
133
175
 
134
176
  class NotFoundException(ApiException):
135
-
136
- def __init__(self, status=None, reason=None, http_resp=None) -> None:
137
- super(NotFoundException, self).__init__(status, reason, http_resp)
177
+ pass
138
178
 
139
179
 
140
180
  class UnauthorizedException(ApiException):
141
-
142
- def __init__(self, status=None, reason=None, http_resp=None) -> None:
143
- super(UnauthorizedException, self).__init__(status, reason, http_resp)
181
+ pass
144
182
 
145
183
 
146
184
  class ForbiddenException(ApiException):
147
-
148
- def __init__(self, status=None, reason=None, http_resp=None) -> None:
149
- super(ForbiddenException, self).__init__(status, reason, http_resp)
185
+ pass
150
186
 
151
187
 
152
188
  class ServiceException(ApiException):
153
-
154
- def __init__(self, status=None, reason=None, http_resp=None) -> None:
155
- super(ServiceException, self).__init__(status, reason, http_resp)
189
+ pass
156
190
 
157
191
 
158
192
  def render_path(path_to_item):
weheat/models/__init__.py CHANGED
@@ -14,11 +14,17 @@
14
14
 
15
15
 
16
16
  # import models into model package
17
+ from weheat.models.boiler_type import BoilerType
17
18
  from weheat.models.device_state import DeviceState
19
+ from weheat.models.dhw_type import DhwType
18
20
  from weheat.models.energy_view_dto import EnergyViewDto
19
21
  from weheat.models.heat_pump_log_view_dto import HeatPumpLogViewDto
22
+ from weheat.models.heat_pump_model import HeatPumpModel
23
+ from weheat.models.heat_pump_status_enum import HeatPumpStatusEnum
24
+ from weheat.models.heat_pump_type import HeatPumpType
20
25
  from weheat.models.raw_heat_pump_log_dto import RawHeatPumpLogDto
21
26
  from weheat.models.read_all_heat_pump_dto import ReadAllHeatPumpDto
22
27
  from weheat.models.read_heat_pump_dto import ReadHeatPumpDto
23
28
  from weheat.models.read_user_dto import ReadUserDto
29
+ from weheat.models.read_user_me_dto import ReadUserMeDto
24
30
  from weheat.models.role import Role
@@ -12,13 +12,18 @@
12
12
  """ # noqa: E501
13
13
 
14
14
 
15
+ from __future__ import annotations
15
16
  import json
16
17
  import pprint
17
18
  import re # noqa: F401
18
- from aenum import Enum, no_arg
19
+ from enum import Enum
19
20
 
20
21
 
21
22
 
23
+ try:
24
+ from typing import Self
25
+ except ImportError:
26
+ from typing_extensions import Self
22
27
 
23
28
 
24
29
  class BoilerType(int, Enum):
@@ -35,8 +40,8 @@ class BoilerType(int, Enum):
35
40
  NUMBER_3 = 3
36
41
 
37
42
  @classmethod
38
- def from_json(cls, json_str: str) -> BoilerType:
43
+ def from_json(cls, json_str: str) -> Self:
39
44
  """Create an instance of BoilerType from a JSON string"""
40
- return BoilerType(json.loads(json_str))
45
+ return cls(json.loads(json_str))
41
46
 
42
47
 
@@ -12,18 +12,23 @@
12
12
  """ # noqa: E501
13
13
 
14
14
 
15
+ from __future__ import annotations
15
16
  import json
16
17
  import pprint
17
18
  import re # noqa: F401
18
- from aenum import Enum, no_arg
19
+ from enum import Enum
19
20
 
20
21
 
21
22
 
23
+ try:
24
+ from typing import Self
25
+ except ImportError:
26
+ from typing_extensions import Self
22
27
 
23
28
 
24
29
  class DeviceState(int, Enum):
25
30
  """
26
- State of the device: - Production (0), - InStock (1), - Sold (2), - Active (3), - Inactive (4), - Broken (5), - Test (6) - Configured (7) For now Production, InStock and Sold will only be applicable to Devices that can be actually installed in installation
31
+ State of the device: - ProductionObsoleteState (0), - InStock (1), - Sold (2), - Active (3), - Inactive (4), - Broken (5), - Test (6) - Configured (7) For now Production, InStock and Sold will only be applicable to Devices that can be actually installed in installation
27
32
  """
28
33
 
29
34
  """
@@ -39,8 +44,8 @@ class DeviceState(int, Enum):
39
44
  NUMBER_7 = 7
40
45
 
41
46
  @classmethod
42
- def from_json(cls, json_str: str) -> DeviceState:
47
+ def from_json(cls, json_str: str) -> Self:
43
48
  """Create an instance of DeviceState from a JSON string"""
44
- return DeviceState(json.loads(json_str))
49
+ return cls(json.loads(json_str))
45
50
 
46
51
 
weheat/models/dhw_type.py CHANGED
@@ -12,13 +12,18 @@
12
12
  """ # noqa: E501
13
13
 
14
14
 
15
+ from __future__ import annotations
15
16
  import json
16
17
  import pprint
17
18
  import re # noqa: F401
18
- from aenum import Enum, no_arg
19
+ from enum import Enum
19
20
 
20
21
 
21
22
 
23
+ try:
24
+ from typing import Self
25
+ except ImportError:
26
+ from typing_extensions import Self
22
27
 
23
28
 
24
29
  class DhwType(int, Enum):
@@ -34,8 +39,8 @@ class DhwType(int, Enum):
34
39
  NUMBER_2 = 2
35
40
 
36
41
  @classmethod
37
- def from_json(cls, json_str: str) -> DhwType:
42
+ def from_json(cls, json_str: str) -> Self:
38
43
  """Create an instance of DhwType from a JSON string"""
39
- return DhwType(json.loads(json_str))
44
+ return cls(json.loads(json_str))
40
45
 
41
46
 
@@ -18,103 +18,118 @@ import re # noqa: F401
18
18
  import json
19
19
 
20
20
  from datetime import datetime
21
- from typing import Optional, Union
21
+ from typing import Any, ClassVar, Dict, List, Optional, Union
22
+ from pydantic import BaseModel, StrictFloat, StrictInt, StrictStr
23
+ from pydantic import Field
22
24
  try:
23
- from pydantic.v1 import BaseModel, Field, StrictFloat, StrictInt, StrictStr
25
+ from typing import Self
24
26
  except ImportError:
25
- from pydantic import BaseModel, Field, StrictFloat, StrictInt, StrictStr
27
+ from typing_extensions import Self
26
28
 
27
29
  class EnergyViewDto(BaseModel):
28
30
  """
29
31
  EnergyViewDto
30
- """
31
- interval: Optional[StrictStr] = Field(None, description="Interval of this EnergyViewDto (Correct intervals include: \"Hour\", \"Day\", \"Week\", \"Month\", \"Year\")")
32
- time_bucket: Optional[datetime] = Field(None, alias="timeBucket")
33
- total_ein_heating: Union[StrictFloat, StrictInt] = Field(..., alias="totalEInHeating", description="Total energy from electricity going into the heat pump for heating for this interval (in kwh)")
34
- total_ein_dhw: Union[StrictFloat, StrictInt] = Field(..., alias="totalEInDhw", description="Total energy from electricity going into the heat pump for doing DHW for this interval (in kwh)")
35
- total_ein_heating_defrost: Union[StrictFloat, StrictInt] = Field(..., alias="totalEInHeatingDefrost", description="Total energy from electricity going into the heat pump for defrosting whilst heating for this interval (in kwh)")
36
- total_ein_dhw_defrost: Union[StrictFloat, StrictInt] = Field(..., alias="totalEInDhwDefrost", description="Total energy from electricity going into the heat pump for defrosting whilst doing DHW for this interval (in kwh)")
37
- total_ein_cooling: Union[StrictFloat, StrictInt] = Field(..., alias="totalEInCooling", description="Total energy from electricity going into the heat pump for cooling for this interval (in kwh)")
38
- total_e_out_heating: Union[StrictFloat, StrictInt] = Field(..., alias="totalEOutHeating", description="Total energy from electricity going out of the heat pump for heating for this interval (in kwh)")
39
- total_e_out_dhw: Union[StrictFloat, StrictInt] = Field(..., alias="totalEOutDhw", description="Total energy from electricity going out of the heat pump for doing DHW for this interval (in kwh)")
40
- total_e_out_heating_defrost: Union[StrictFloat, StrictInt] = Field(..., alias="totalEOutHeatingDefrost", description="Total energy from electricity going out of the heat pump for defrosting whilst heating for this interval (in kwh)")
41
- total_e_out_dhw_defrost: Union[StrictFloat, StrictInt] = Field(..., alias="totalEOutDhwDefrost", description="Total energy from electricity going out of the heat pump for defrosting whilst doing DHW for this interval (in kwh)")
42
- total_e_out_cooling: Union[StrictFloat, StrictInt] = Field(..., alias="totalEOutCooling", description="Total energy from electricity going out of the heat pump for cooling for this interval (in kwh)")
43
- average_power_ein_heating: Union[StrictFloat, StrictInt] = Field(..., alias="averagePowerEInHeating", description="Average power from electricity going into the heat pump for heating for this interval (in kW)")
44
- average_power_ein_dhw: Union[StrictFloat, StrictInt] = Field(..., alias="averagePowerEInDhw", description="Average power from electricity going into the heat pump for doing DHW for this interval (in kW)")
45
- average_power_ein_heating_defrost: Union[StrictFloat, StrictInt] = Field(..., alias="averagePowerEInHeatingDefrost", description="Average power from electricity going into the heat pump for defrosting whilst heating for this interval (in kW)")
46
- average_power_ein_dhw_defrost: Union[StrictFloat, StrictInt] = Field(..., alias="averagePowerEInDhwDefrost", description="Average power from electricity going into the heat pump for defrosting whilst doing DHW for this interval (in kW)")
47
- average_power_ein_cooling: Union[StrictFloat, StrictInt] = Field(..., alias="averagePowerEInCooling", description="Average power from electricity going into the heat pump for cooling for this interval (in kW)")
48
- average_power_e_out_heating: Union[StrictFloat, StrictInt] = Field(..., alias="averagePowerEOutHeating", description="Average power from electricity going out of the heat pump for heating for this interval (in kW)")
49
- average_power_e_out_dhw: Union[StrictFloat, StrictInt] = Field(..., alias="averagePowerEOutDhw", description="Average power from electricity going out of the heat pump for doing DHW for this interval (in kW)")
50
- average_power_e_out_heating_defrost: Union[StrictFloat, StrictInt] = Field(..., alias="averagePowerEOutHeatingDefrost", description="Average power from electricity going out of the heat pump for defrosting whilst heating for this interval (in kW)")
51
- average_power_e_out_dhw_defrost: Union[StrictFloat, StrictInt] = Field(..., alias="averagePowerEOutDhwDefrost", description="Average power from electricity going out of the heat pump for defrosting whilst doing DHW for this interval (in kW)")
52
- average_power_e_out_cooling: Union[StrictFloat, StrictInt] = Field(..., alias="averagePowerEOutCooling", description="Average power from electricity going out of the heat pump for cooling for this interval (in kW)")
53
- __properties = ["interval", "timeBucket", "totalEInHeating", "totalEInDhw", "totalEInHeatingDefrost", "totalEInDhwDefrost", "totalEInCooling", "totalEOutHeating", "totalEOutDhw", "totalEOutHeatingDefrost", "totalEOutDhwDefrost", "totalEOutCooling", "averagePowerEInHeating", "averagePowerEInDhw", "averagePowerEInHeatingDefrost", "averagePowerEInDhwDefrost", "averagePowerEInCooling", "averagePowerEOutHeating", "averagePowerEOutDhw", "averagePowerEOutHeatingDefrost", "averagePowerEOutDhwDefrost", "averagePowerEOutCooling"]
54
-
55
- class Config:
56
- """Pydantic configuration"""
57
- allow_population_by_field_name = True
58
- validate_assignment = True
32
+ """ # noqa: E501
33
+ interval: Optional[StrictStr] = Field(default=None, description="Interval of this EnergyViewDto (Correct intervals include: \"Hour\", \"Day\", \"Week\", \"Month\", \"Year\")")
34
+ time_bucket: Optional[datetime] = Field(default=None, alias="timeBucket")
35
+ total_ein_heating: Union[StrictFloat, StrictInt] = Field(description="Total energy from electricity going into the heat pump for heating for this interval (in kwh)", alias="totalEInHeating")
36
+ total_ein_dhw: Union[StrictFloat, StrictInt] = Field(description="Total energy from electricity going into the heat pump for doing DHW for this interval (in kwh)", alias="totalEInDhw")
37
+ total_ein_heating_defrost: Union[StrictFloat, StrictInt] = Field(description="Total energy from electricity going into the heat pump for defrosting whilst heating for this interval (in kwh)", alias="totalEInHeatingDefrost")
38
+ total_ein_dhw_defrost: Union[StrictFloat, StrictInt] = Field(description="Total energy from electricity going into the heat pump for defrosting whilst doing DHW for this interval (in kwh)", alias="totalEInDhwDefrost")
39
+ total_ein_cooling: Union[StrictFloat, StrictInt] = Field(description="Total energy from electricity going into the heat pump for cooling for this interval (in kwh)", alias="totalEInCooling")
40
+ total_e_out_heating: Union[StrictFloat, StrictInt] = Field(description="Total energy from electricity going out of the heat pump for heating for this interval (in kwh)", alias="totalEOutHeating")
41
+ total_e_out_dhw: Union[StrictFloat, StrictInt] = Field(description="Total energy from electricity going out of the heat pump for doing DHW for this interval (in kwh)", alias="totalEOutDhw")
42
+ total_e_out_heating_defrost: Union[StrictFloat, StrictInt] = Field(description="Total energy from electricity going out of the heat pump for defrosting whilst heating for this interval (in kwh)", alias="totalEOutHeatingDefrost")
43
+ total_e_out_dhw_defrost: Union[StrictFloat, StrictInt] = Field(description="Total energy from electricity going out of the heat pump for defrosting whilst doing DHW for this interval (in kwh)", alias="totalEOutDhwDefrost")
44
+ total_e_out_cooling: Union[StrictFloat, StrictInt] = Field(description="Total energy from electricity going out of the heat pump for cooling for this interval (in kwh)", alias="totalEOutCooling")
45
+ average_power_ein_heating: Union[StrictFloat, StrictInt] = Field(description="Average power from electricity going into the heat pump for heating for this interval (in kW)", alias="averagePowerEInHeating")
46
+ average_power_ein_dhw: Union[StrictFloat, StrictInt] = Field(description="Average power from electricity going into the heat pump for doing DHW for this interval (in kW)", alias="averagePowerEInDhw")
47
+ average_power_ein_heating_defrost: Union[StrictFloat, StrictInt] = Field(description="Average power from electricity going into the heat pump for defrosting whilst heating for this interval (in kW)", alias="averagePowerEInHeatingDefrost")
48
+ average_power_ein_dhw_defrost: Union[StrictFloat, StrictInt] = Field(description="Average power from electricity going into the heat pump for defrosting whilst doing DHW for this interval (in kW)", alias="averagePowerEInDhwDefrost")
49
+ average_power_ein_cooling: Union[StrictFloat, StrictInt] = Field(description="Average power from electricity going into the heat pump for cooling for this interval (in kW)", alias="averagePowerEInCooling")
50
+ average_power_e_out_heating: Union[StrictFloat, StrictInt] = Field(description="Average power from electricity going out of the heat pump for heating for this interval (in kW)", alias="averagePowerEOutHeating")
51
+ average_power_e_out_dhw: Union[StrictFloat, StrictInt] = Field(description="Average power from electricity going out of the heat pump for doing DHW for this interval (in kW)", alias="averagePowerEOutDhw")
52
+ average_power_e_out_heating_defrost: Union[StrictFloat, StrictInt] = Field(description="Average power from electricity going out of the heat pump for defrosting whilst heating for this interval (in kW)", alias="averagePowerEOutHeatingDefrost")
53
+ average_power_e_out_dhw_defrost: Union[StrictFloat, StrictInt] = Field(description="Average power from electricity going out of the heat pump for defrosting whilst doing DHW for this interval (in kW)", alias="averagePowerEOutDhwDefrost")
54
+ average_power_e_out_cooling: Union[StrictFloat, StrictInt] = Field(description="Average power from electricity going out of the heat pump for cooling for this interval (in kW)", alias="averagePowerEOutCooling")
55
+ __properties: ClassVar[List[str]] = ["interval", "timeBucket", "totalEInHeating", "totalEInDhw", "totalEInHeatingDefrost", "totalEInDhwDefrost", "totalEInCooling", "totalEOutHeating", "totalEOutDhw", "totalEOutHeatingDefrost", "totalEOutDhwDefrost", "totalEOutCooling", "averagePowerEInHeating", "averagePowerEInDhw", "averagePowerEInHeatingDefrost", "averagePowerEInDhwDefrost", "averagePowerEInCooling", "averagePowerEOutHeating", "averagePowerEOutDhw", "averagePowerEOutHeatingDefrost", "averagePowerEOutDhwDefrost", "averagePowerEOutCooling"]
56
+
57
+ model_config = {
58
+ "populate_by_name": True,
59
+ "validate_assignment": True,
60
+ "protected_namespaces": (),
61
+ }
62
+
59
63
 
60
64
  def to_str(self) -> str:
61
65
  """Returns the string representation of the model using alias"""
62
- return pprint.pformat(self.dict(by_alias=True))
66
+ return pprint.pformat(self.model_dump(by_alias=True))
63
67
 
64
68
  def to_json(self) -> str:
65
69
  """Returns the JSON representation of the model using alias"""
70
+ # TODO: pydantic v2: use .model_dump_json(by_alias=True, exclude_unset=True) instead
66
71
  return json.dumps(self.to_dict())
67
72
 
68
73
  @classmethod
69
- def from_json(cls, json_str: str) -> EnergyViewDto:
74
+ def from_json(cls, json_str: str) -> Self:
70
75
  """Create an instance of EnergyViewDto from a JSON string"""
71
76
  return cls.from_dict(json.loads(json_str))
72
77
 
73
- def to_dict(self):
74
- """Returns the dictionary representation of the model using alias"""
75
- _dict = self.dict(by_alias=True,
76
- exclude={
77
- },
78
- exclude_none=True)
78
+ def to_dict(self) -> Dict[str, Any]:
79
+ """Return the dictionary representation of the model using alias.
80
+
81
+ This has the following differences from calling pydantic's
82
+ `self.model_dump(by_alias=True)`:
83
+
84
+ * `None` is only added to the output dict for nullable fields that
85
+ were set at model initialization. Other fields with value `None`
86
+ are ignored.
87
+ """
88
+ _dict = self.model_dump(
89
+ by_alias=True,
90
+ exclude={
91
+ },
92
+ exclude_none=True,
93
+ )
79
94
  # set to None if interval (nullable) is None
80
- # and __fields_set__ contains the field
81
- if self.interval is None and "interval" in self.__fields_set__:
95
+ # and model_fields_set contains the field
96
+ if self.interval is None and "interval" in self.model_fields_set:
82
97
  _dict['interval'] = None
83
98
 
84
99
  return _dict
85
100
 
86
101
  @classmethod
87
- def from_dict(cls, obj: dict) -> EnergyViewDto:
102
+ def from_dict(cls, obj: Dict) -> Self:
88
103
  """Create an instance of EnergyViewDto from a dict"""
89
104
  if obj is None:
90
105
  return None
91
106
 
92
107
  if not isinstance(obj, dict):
93
- return EnergyViewDto.parse_obj(obj)
108
+ return cls.model_validate(obj)
94
109
 
95
- _obj = EnergyViewDto.parse_obj({
110
+ _obj = cls.model_validate({
96
111
  "interval": obj.get("interval"),
97
- "time_bucket": obj.get("timeBucket"),
98
- "total_ein_heating": obj.get("totalEInHeating"),
99
- "total_ein_dhw": obj.get("totalEInDhw"),
100
- "total_ein_heating_defrost": obj.get("totalEInHeatingDefrost"),
101
- "total_ein_dhw_defrost": obj.get("totalEInDhwDefrost"),
102
- "total_ein_cooling": obj.get("totalEInCooling"),
103
- "total_e_out_heating": obj.get("totalEOutHeating"),
104
- "total_e_out_dhw": obj.get("totalEOutDhw"),
105
- "total_e_out_heating_defrost": obj.get("totalEOutHeatingDefrost"),
106
- "total_e_out_dhw_defrost": obj.get("totalEOutDhwDefrost"),
107
- "total_e_out_cooling": obj.get("totalEOutCooling"),
108
- "average_power_ein_heating": obj.get("averagePowerEInHeating"),
109
- "average_power_ein_dhw": obj.get("averagePowerEInDhw"),
110
- "average_power_ein_heating_defrost": obj.get("averagePowerEInHeatingDefrost"),
111
- "average_power_ein_dhw_defrost": obj.get("averagePowerEInDhwDefrost"),
112
- "average_power_ein_cooling": obj.get("averagePowerEInCooling"),
113
- "average_power_e_out_heating": obj.get("averagePowerEOutHeating"),
114
- "average_power_e_out_dhw": obj.get("averagePowerEOutDhw"),
115
- "average_power_e_out_heating_defrost": obj.get("averagePowerEOutHeatingDefrost"),
116
- "average_power_e_out_dhw_defrost": obj.get("averagePowerEOutDhwDefrost"),
117
- "average_power_e_out_cooling": obj.get("averagePowerEOutCooling")
112
+ "timeBucket": obj.get("timeBucket"),
113
+ "totalEInHeating": obj.get("totalEInHeating"),
114
+ "totalEInDhw": obj.get("totalEInDhw"),
115
+ "totalEInHeatingDefrost": obj.get("totalEInHeatingDefrost"),
116
+ "totalEInDhwDefrost": obj.get("totalEInDhwDefrost"),
117
+ "totalEInCooling": obj.get("totalEInCooling"),
118
+ "totalEOutHeating": obj.get("totalEOutHeating"),
119
+ "totalEOutDhw": obj.get("totalEOutDhw"),
120
+ "totalEOutHeatingDefrost": obj.get("totalEOutHeatingDefrost"),
121
+ "totalEOutDhwDefrost": obj.get("totalEOutDhwDefrost"),
122
+ "totalEOutCooling": obj.get("totalEOutCooling"),
123
+ "averagePowerEInHeating": obj.get("averagePowerEInHeating"),
124
+ "averagePowerEInDhw": obj.get("averagePowerEInDhw"),
125
+ "averagePowerEInHeatingDefrost": obj.get("averagePowerEInHeatingDefrost"),
126
+ "averagePowerEInDhwDefrost": obj.get("averagePowerEInDhwDefrost"),
127
+ "averagePowerEInCooling": obj.get("averagePowerEInCooling"),
128
+ "averagePowerEOutHeating": obj.get("averagePowerEOutHeating"),
129
+ "averagePowerEOutDhw": obj.get("averagePowerEOutDhw"),
130
+ "averagePowerEOutHeatingDefrost": obj.get("averagePowerEOutHeatingDefrost"),
131
+ "averagePowerEOutDhwDefrost": obj.get("averagePowerEOutDhwDefrost"),
132
+ "averagePowerEOutCooling": obj.get("averagePowerEOutCooling")
118
133
  })
119
134
  return _obj
120
135