dimplex-controller 0.7.0__tar.gz → 0.8.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dimplex-controller
3
- Version: 0.7.0
3
+ Version: 0.8.0
4
4
  Summary: Python client for Dimplex heating controllers (GDHV IoT)
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -22,7 +22,6 @@ Classifier: Topic :: Home Automation
22
22
  Requires-Dist: aiohttp (>=3.9.0,<4.0.0)
23
23
  Requires-Dist: beautifulsoup4 (>=4.14.3,<5.0.0)
24
24
  Requires-Dist: pydantic (>=2.0.0,<3.0.0)
25
- Requires-Dist: python-dotenv (>=1.2.1,<2.0.0)
26
25
  Project-URL: Homepage, https://github.com/KRoperUK/dimplex-controller-py
27
26
  Project-URL: Repository, https://github.com/KRoperUK/dimplex-controller-py
28
27
  Description-Content-Type: text/markdown
@@ -10,6 +10,7 @@ from .models import (
10
10
  ApplianceStatus,
11
11
  AutomaticProvisioning,
12
12
  Hub,
13
+ ProductModel,
13
14
  TimerMode,
14
15
  TimerModeSettings,
15
16
  TimerPeriod,
@@ -37,6 +38,7 @@ __all__ = [
37
38
  "TimerModeSettings",
38
39
  "TimerPeriod",
39
40
  "AutomaticProvisioning",
41
+ "ProductModel",
40
42
  "TsiEnergyReport",
41
43
  "parse_telemetry_points",
42
44
  "filter_telemetry_points",
@@ -24,6 +24,7 @@ from .models import (
24
24
  ApplianceModeSettings,
25
25
  ApplianceStatus,
26
26
  Hub,
27
+ ProductModel,
27
28
  TimerMode,
28
29
  TimerModeSettings,
29
30
  TimerPeriod,
@@ -174,6 +175,16 @@ class DimplexControl:
174
175
  data = await self._request("GET", "/Identity/GetUserContext")
175
176
  return UserContext.model_validate(data)
176
177
 
178
+ async def get_product_models(self) -> list[ProductModel]:
179
+ """Return the cloud product catalogue (models + provisioning metadata).
180
+
181
+ The catalogue is largely static; callers may cache the result.
182
+ """
183
+ data = await self._request("GET", "/Appliances/GetProductModels")
184
+ if not data:
185
+ return []
186
+ return [ProductModel.model_validate(item) for item in data]
187
+
177
188
  async def get_appliance_features(self, hub_id: str, appliance_id: str) -> TimerModeSettings:
178
189
  """Get timer details (and mode) for an appliance."""
179
190
  payload = {
@@ -4,7 +4,7 @@ import json
4
4
  from datetime import datetime, time
5
5
  from enum import IntEnum, IntFlag
6
6
 
7
- from pydantic import BaseModel, Field, field_validator
7
+ from pydantic import BaseModel, ConfigDict, Field, field_validator
8
8
 
9
9
 
10
10
  class TimerMode(IntEnum):
@@ -39,8 +39,16 @@ class AutomaticProvisioning(BaseModel):
39
39
 
40
40
  The cloud stores this as a JSON string; :class:`Appliance` decodes it
41
41
  automatically so callers can read the heater's electrical characteristics.
42
+
43
+ Observed units (from product catalogue / live Quantum payloads):
44
+
45
+ * power ratings — kW
46
+ * charge capacity — kWh
47
+ * charge element resistance — ohms
42
48
  """
43
49
 
50
+ model_config = ConfigDict(populate_by_name=True)
51
+
44
52
  bottom_element_power_rating: float | None = Field(None, alias="bottomElementPowerRating")
45
53
  top_element_power_rating: float | None = Field(None, alias="topElementPowerRating")
46
54
  rated_power: float | None = Field(None, alias="ratedPower")
@@ -49,6 +57,38 @@ class AutomaticProvisioning(BaseModel):
49
57
  power_offset: float | None = Field(None, alias="powerOffset")
50
58
 
51
59
 
60
+ class ProductModel(BaseModel):
61
+ """A row from ``GET /Appliances/GetProductModels``."""
62
+
63
+ model_config = ConfigDict(populate_by_name=True)
64
+
65
+ ProductModelId: str | None = None
66
+ ProductTypeId: str | None = None
67
+ ProductModelName: str | None = None
68
+ ProductTypeName: str | None = None
69
+ ProductModelExtensions: dict[str, str] | None = None
70
+
71
+ @field_validator("ProductModelExtensions", mode="before")
72
+ @classmethod
73
+ def _coerce_extensions(cls, value):
74
+ if value is None:
75
+ return None
76
+ if isinstance(value, dict):
77
+ return {str(k): v if isinstance(v, str) else json.dumps(v) for k, v in value.items()}
78
+ return value
79
+
80
+ @property
81
+ def automatic_provisioning(self) -> AutomaticProvisioning | None:
82
+ """Return decoded AUTOMATIC_PROVISIONING, if present."""
83
+ raw = (self.ProductModelExtensions or {}).get("AUTOMATIC_PROVISIONING")
84
+ if not raw:
85
+ return None
86
+ try:
87
+ return AutomaticProvisioning.model_validate_json(raw)
88
+ except (json.JSONDecodeError, ValueError):
89
+ return None
90
+
91
+
52
92
  class Appliance(BaseModel):
53
93
  ApplianceId: str
54
94
  ApplianceType: str
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "dimplex-controller"
3
- version = "0.7.0"
3
+ version = "0.8.0"
4
4
  description = "Python client for Dimplex heating controllers (GDHV IoT)"
5
5
  authors = ["Kieran Roper"]
6
6
  license = "MIT"
@@ -28,7 +28,7 @@ python = "^3.10"
28
28
  aiohttp = "^3.9.0"
29
29
  pydantic = "^2.0.0"
30
30
  beautifulsoup4 = "^4.14.3"
31
- python-dotenv = "^1.2.1"
31
+
32
32
  [tool.poetry.group.dev.dependencies]
33
33
  pytest = "^8.0.0"
34
34
  pytest-asyncio = "^0.23.0"
@@ -37,6 +37,8 @@ aresponses = "^3.0.0"
37
37
  ruff = "^0.3.0"
38
38
  pre-commit = "^3.6.0"
39
39
  twine = "^6.2.0"
40
+ python-dotenv = "^1.2.1"
41
+ mypy = "^1.0.0"
40
42
 
41
43
  [tool.ruff]
42
44
  line-length = 120