python-tado 1.0.1rc1__tar.gz → 1.0.1rc2__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.
Files changed (49) hide show
  1. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PKG-INFO +28 -3
  2. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/factory/initializer.py +12 -1
  3. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/interface/interface.py +21 -0
  4. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/models/home.py +10 -4
  5. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/models/line_x/device.py +2 -2
  6. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/models/pre_line_x/zone.py +2 -2
  7. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/types.py +36 -7
  8. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/README.md +27 -2
  9. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/pyproject.toml +1 -1
  10. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/AUTHORS +0 -0
  11. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/LICENSE +0 -0
  12. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/__init__.py +0 -0
  13. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/__main__.py +0 -0
  14. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/const.py +0 -0
  15. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/exceptions.py +0 -0
  16. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/factory/__init__.py +0 -0
  17. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/http.py +0 -0
  18. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/interface/__init__.py +0 -0
  19. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/interface/api/__init__.py +0 -0
  20. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/interface/api/base_tado.py +0 -0
  21. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/interface/api/hops_tado.py +0 -0
  22. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/interface/api/my_tado.py +0 -0
  23. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/logger.py +0 -0
  24. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/models/__init__.py +0 -0
  25. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/models/common/__init__.py +0 -0
  26. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/models/common/schedule.py +0 -0
  27. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/models/historic.py +0 -0
  28. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/models/line_x/__init__.py +0 -0
  29. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/models/line_x/installation.py +0 -0
  30. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/models/line_x/room.py +0 -0
  31. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/models/line_x/schedule.py +0 -0
  32. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/models/pre_line_x/__init__.py +0 -0
  33. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/models/pre_line_x/boiler.py +0 -0
  34. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/models/pre_line_x/device.py +0 -0
  35. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/models/pre_line_x/flow_temperature_optimization.py +0 -0
  36. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/models/pre_line_x/home.py +0 -0
  37. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/models/pre_line_x/schedule.py +0 -0
  38. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/models/return_models.py +0 -0
  39. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/models/util.py +0 -0
  40. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/token_manager/__init__.py +0 -0
  41. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/token_manager/can_manage_device_activation.py +0 -0
  42. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/token_manager/device_token_manager.py +0 -0
  43. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/token_manager/dummy_device_manager.py +0 -0
  44. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/token_manager/file_token_manager.py +0 -0
  45. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/token_manager/token_manager_interface.py +0 -0
  46. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/zone/__init__.py +0 -0
  47. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/zone/base_zone.py +0 -0
  48. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/zone/hops_zone.py +0 -0
  49. {python_tado-1.0.1rc1 → python_tado-1.0.1rc2}/PyTado/zone/my_zone.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-tado
3
- Version: 1.0.1rc1
3
+ Version: 1.0.1rc2
4
4
  Summary: PyTado from chrism0dwk, modified by w.malgadey, diplix, michaelarnauts, LenhartStephan, splifter, syssi, andersonshatch, Yippy, p0thi, Coffee2CodeNL, chiefdragon, FilBr, nikilase, albertomontesg, Moritz-Schmidt, palazzem
5
5
  License: GPL-3.0-or-later
6
6
  License-File: AUTHORS
@@ -79,13 +79,13 @@ cause discomfort and inconvenience to others.
79
79
 
80
80
  | Line | API | Status | Branch |
81
81
  | ---- | --- | ------ | ------ |
82
- | **1.x** (from 1.0.1) | New typed API: pydantic models instead of `dict`, separate clients for tado v2/v3/v3+ (`Tado`) and tado X (`TadoX`), `TadoClientInitializer`, token managers that share one login between processes. Needs `pydantic` 2. | Under active development | `master` |
82
+ | **1.x** (from 1.0.1) | New typed API: pydantic models instead of `dict`, separate clients for tado v2/v3/v3+ and tado X behind `PyTado.interface.Tado` (typed via `tado.client`), token managers that share one login between processes. Needs `pydantic` 2. | Under active development | `master` |
83
83
  | **0.18.x** | Old API: methods return plain `dict`/`list`, one `Tado` class for all devices. | Maintained, bug fixes and backports | `support/0.18` |
84
84
  | **0.19.x** | Same old API as 0.18.x (0.19.0 brought the OAuth device flow, child lock and flow temperature optimization, which were all backported to 0.18.x). | Frozen, use 0.18.x | `support/0.19` |
85
85
 
86
86
  The 1.x API is not compatible with 0.x. See the [migration guide](https://github.com/wmalgadey/PyTado/blob/master/MigrationV1.0.0.md).
87
87
 
88
- Pin the line you need, e.g. `python-tado~=0.18.17` for the old API or `python-tado>=1.0.1,<2` for the new one. Until 1.0.1 final is out, the new API is only available as a release candidate: `pip install --pre "python-tado>=1.0.1rc1,<2"`.
88
+ Pin the line you need, e.g. `python-tado~=0.18.17` for the old API or `python-tado>=1.0.1,<2` for the new one. Until 1.0.1 final is out, the new API is only available as a release candidate: `pip install --pre "python-tado>=1.0.1rc2,<2"`.
89
89
 
90
90
  ### Releases to avoid
91
91
 
@@ -189,6 +189,31 @@ if __name__ == "__main__":
189
189
  main()
190
190
  ```
191
191
 
192
+ ### Typed access to the client
193
+
194
+ `Tado` forwards every other call (`get_zones()`, `get_zone_states()`, …) to the client for your
195
+ tado generation, but a type checker only sees `Any` for these calls. For typed results, use the
196
+ `client` property. It returns `PyTado.interface.api.Tado` (tado v2/v3/v3+) or
197
+ `PyTado.interface.api.TadoX` (tado X):
198
+
199
+ ```python
200
+ from PyTado.interface import Tado
201
+ from PyTado.interface.api import TadoX
202
+
203
+ tado = Tado(token_file_path="/var/tado/refresh_token")
204
+ # ... device activation as above ...
205
+
206
+ client = tado.client
207
+ zones = client.get_zones() # typed: list[TadoZone] | list[TadoRoom]
208
+
209
+ if isinstance(client, TadoX):
210
+ # functions only tado X has, e.g. boosting all rooms at once
211
+ client.boost_all_heating()
212
+ ```
213
+
214
+ `PyTado.factory.TadoClientInitializer` is deprecated since 1.0.1 and will be removed in 2.0. Use
215
+ `PyTado.interface.Tado` instead.
216
+
192
217
  Note: For developers, there is an `example.py` script in `examples/` which is configured to fetch data from your account.
193
218
  You can then invoke `python examples/example.py`.
194
219
 
@@ -2,6 +2,7 @@
2
2
  PyTado API factory to use app.tado.com or hops.tado.com
3
3
  """
4
4
 
5
+ import warnings
5
6
  from typing import Callable, Self
6
7
 
7
8
  import requests
@@ -13,7 +14,11 @@ from PyTado.token_manager import TokenManagerInterface
13
14
 
14
15
 
15
16
  class TadoClientInitializer:
16
- """Class to authenticate and get the Tado client."""
17
+ """Class to authenticate and get the Tado client.
18
+
19
+ Deprecated: use ``PyTado.interface.Tado`` and its typed ``client`` property instead.
20
+ This class will be removed in 2.0.
21
+ """
17
22
 
18
23
  http: Http
19
24
  debug: bool = False
@@ -33,6 +38,12 @@ class TadoClientInitializer:
33
38
  token_manager: TokenManagerInterface | None = None,
34
39
  ):
35
40
  """Takes the same login options as PyTado.interface.Tado."""
41
+ warnings.warn(
42
+ "TadoClientInitializer is deprecated and will be removed in 2.0. "
43
+ "Use PyTado.interface.Tado and its typed 'client' property instead.",
44
+ DeprecationWarning,
45
+ stacklevel=2,
46
+ )
36
47
  self.token_file_path = token_file_path
37
48
  self.saved_refresh_token = saved_refresh_token
38
49
  self.http_session = http_session
@@ -162,6 +162,27 @@ class Tado:
162
162
  """
163
163
  return self._http.rate_limit
164
164
 
165
+ @property
166
+ def client(self) -> API.Tado | API.TadoX:
167
+ """
168
+ The detected API client, statically typed.
169
+
170
+ Calls on this object are forwarded to the same client, but a type checker only
171
+ sees ``Any`` for them. Use ``client`` when you want typed results, and narrow it
172
+ with ``isinstance(tado.client, PyTado.interface.api.TadoX)`` for tado X only
173
+ functions.
174
+
175
+ Returns:
176
+ PyTado.interface.api.Tado | PyTado.interface.api.TadoX: the client for the
177
+ tado generation of this home
178
+
179
+ Raises:
180
+ TadoException: If device authentication is not completed
181
+ """
182
+ self._ensure_api_initialized()
183
+ # _ensure_api_initialized either sets _api or raises
184
+ return cast(API.Tado | API.TadoX, self._api)
185
+
165
186
  def _ensure_api_initialized(self) -> None:
166
187
  """
167
188
  Ensures the API client is initialized.
@@ -4,7 +4,13 @@ from typing import Any, Dict
4
4
  from pydantic import model_validator
5
5
 
6
6
  from PyTado.models.util import Base
7
- from PyTado.types import BatteryState, Presence
7
+ from PyTado.types import (
8
+ AirFreshness,
9
+ BatteryState,
10
+ HumidityLevel,
11
+ Presence,
12
+ TemperatureLevel,
13
+ )
8
14
 
9
15
 
10
16
  class User(Base):
@@ -136,7 +142,7 @@ class MobileDevice(Base):
136
142
 
137
143
 
138
144
  class Freshness(Base):
139
- value: str # TODO: use Enum or similar
145
+ value: AirFreshness
140
146
  last_open_window: datetime
141
147
 
142
148
 
@@ -147,8 +153,8 @@ class RoomComfortCoordinate(Base):
147
153
 
148
154
  class RoomComfort(Base):
149
155
  room_id: int
150
- temperature_level: str | None = None # TODO: use Enum or similar
151
- humidity_level: str | None = None # TODO: use Enum or similar
156
+ temperature_level: TemperatureLevel | None = None
157
+ humidity_level: HumidityLevel | None = None
152
158
  coordinate: RoomComfortCoordinate | None = None
153
159
 
154
160
 
@@ -3,7 +3,7 @@ from typing import Any, Self
3
3
  from pydantic import model_validator
4
4
 
5
5
  from PyTado.models.util import Base
6
- from PyTado.types import BatteryState, ConnectionState, OverlayMode
6
+ from PyTado.types import BatteryState, ConnectionState, MountingState, OverlayMode
7
7
 
8
8
 
9
9
  class Connection(Base):
@@ -17,7 +17,7 @@ class Device(Base):
17
17
  type: str
18
18
  firmware_version: str
19
19
  connection: Connection
20
- mounting_state: str | None = None # TODO: Use Enum or something similar
20
+ mounting_state: MountingState | None = None
21
21
  battery_state: BatteryState | None = None
22
22
  child_lock_enabled: bool | None = None
23
23
  temperature_as_measured: float | None = None
@@ -63,7 +63,7 @@ class HeatingPower(Base):
63
63
  """HeatingPower model represents the heating power."""
64
64
 
65
65
  percentage: float
66
- type: str | None = None # TODO: use Enum for this
66
+ type: str | None = None # only "POWER" seen; a discriminator, kept as str
67
67
  timestamp: datetime | None = None
68
68
  # TODO: Check if this is still used!
69
69
  value: str | None = None
@@ -72,7 +72,7 @@ class HeatingPower(Base):
72
72
  class AcPower(Base):
73
73
  """AcPower model represents the AC power."""
74
74
 
75
- type: str # TODO: use Enum for this
75
+ type: str # only "POWER" seen; a discriminator, kept as str
76
76
  timestamp: datetime
77
77
  value: Power
78
78
 
@@ -27,20 +27,19 @@ class StrEnumMissing(StrEnum):
27
27
  The `__str__` method is overridden to return the enum member's name as its string
28
28
  representation.
29
29
 
30
- This class is useful for debugging and gracefully handling unexpected enum values, but
31
- the `_missing_` method can be removed if not needed.
30
+ Do not remove `_missing_`: model fields typed with these enums rely on it, so that a value
31
+ tado adds later (or one we don't know yet) doesn't make parsing the whole response fail.
32
+ Because these are `StrEnum`s, members also compare equal to their plain string value.
32
33
  """
33
34
 
34
35
  def __str__(self) -> str:
35
36
  return self.name
36
37
 
37
38
  @classmethod
38
- def _missing_(cls, value: Any) -> Any: # pragma: no cover
39
- """Debug missing enum values and return a missing value.
40
- (This is just for debugging, can be removed if not needed anymore)
41
- """
39
+ def _missing_(cls, value: Any) -> Any:
40
+ """Log an unknown value and return a member for it instead of raising."""
42
41
  logger.debug("enum %s is missing key %r", cls, value)
43
- unknown_enum_val = str.__new__(cls)
42
+ unknown_enum_val = str.__new__(cls, value)
44
43
  unknown_enum_val._name_ = str(value)
45
44
  unknown_enum_val._value_ = value
46
45
  return unknown_enum_val
@@ -205,3 +204,33 @@ class Unit(StrEnumMissing):
205
204
 
206
205
  M3 = "m3"
207
206
  KWH = "kWh"
207
+
208
+
209
+ class AirFreshness(StrEnumMissing):
210
+ """How fresh the air in the home is (air comfort)"""
211
+
212
+ FRESH = "FRESH"
213
+ FAIR = "FAIR"
214
+ STALE = "STALE"
215
+
216
+
217
+ class TemperatureLevel(StrEnumMissing):
218
+ """How a room's temperature feels (air comfort)"""
219
+
220
+ COLD = "COLD"
221
+ COMFY = "COMFY"
222
+ HOT = "HOT"
223
+
224
+
225
+ class HumidityLevel(StrEnumMissing):
226
+ """How a room's humidity feels (air comfort)"""
227
+
228
+ DRY = "DRY"
229
+ COMFY = "COMFY"
230
+ HUMID = "HUMID"
231
+
232
+
233
+ class MountingState(StrEnumMissing):
234
+ """Mounting state of a tado X device; other values are kept as they come"""
235
+
236
+ CALIBRATED = "CALIBRATED"
@@ -33,13 +33,13 @@ cause discomfort and inconvenience to others.
33
33
 
34
34
  | Line | API | Status | Branch |
35
35
  | ---- | --- | ------ | ------ |
36
- | **1.x** (from 1.0.1) | New typed API: pydantic models instead of `dict`, separate clients for tado v2/v3/v3+ (`Tado`) and tado X (`TadoX`), `TadoClientInitializer`, token managers that share one login between processes. Needs `pydantic` 2. | Under active development | `master` |
36
+ | **1.x** (from 1.0.1) | New typed API: pydantic models instead of `dict`, separate clients for tado v2/v3/v3+ and tado X behind `PyTado.interface.Tado` (typed via `tado.client`), token managers that share one login between processes. Needs `pydantic` 2. | Under active development | `master` |
37
37
  | **0.18.x** | Old API: methods return plain `dict`/`list`, one `Tado` class for all devices. | Maintained, bug fixes and backports | `support/0.18` |
38
38
  | **0.19.x** | Same old API as 0.18.x (0.19.0 brought the OAuth device flow, child lock and flow temperature optimization, which were all backported to 0.18.x). | Frozen, use 0.18.x | `support/0.19` |
39
39
 
40
40
  The 1.x API is not compatible with 0.x. See the [migration guide](https://github.com/wmalgadey/PyTado/blob/master/MigrationV1.0.0.md).
41
41
 
42
- Pin the line you need, e.g. `python-tado~=0.18.17` for the old API or `python-tado>=1.0.1,<2` for the new one. Until 1.0.1 final is out, the new API is only available as a release candidate: `pip install --pre "python-tado>=1.0.1rc1,<2"`.
42
+ Pin the line you need, e.g. `python-tado~=0.18.17` for the old API or `python-tado>=1.0.1,<2` for the new one. Until 1.0.1 final is out, the new API is only available as a release candidate: `pip install --pre "python-tado>=1.0.1rc2,<2"`.
43
43
 
44
44
  ### Releases to avoid
45
45
 
@@ -143,6 +143,31 @@ if __name__ == "__main__":
143
143
  main()
144
144
  ```
145
145
 
146
+ ### Typed access to the client
147
+
148
+ `Tado` forwards every other call (`get_zones()`, `get_zone_states()`, …) to the client for your
149
+ tado generation, but a type checker only sees `Any` for these calls. For typed results, use the
150
+ `client` property. It returns `PyTado.interface.api.Tado` (tado v2/v3/v3+) or
151
+ `PyTado.interface.api.TadoX` (tado X):
152
+
153
+ ```python
154
+ from PyTado.interface import Tado
155
+ from PyTado.interface.api import TadoX
156
+
157
+ tado = Tado(token_file_path="/var/tado/refresh_token")
158
+ # ... device activation as above ...
159
+
160
+ client = tado.client
161
+ zones = client.get_zones() # typed: list[TadoZone] | list[TadoRoom]
162
+
163
+ if isinstance(client, TadoX):
164
+ # functions only tado X has, e.g. boosting all rooms at once
165
+ client.boost_all_heating()
166
+ ```
167
+
168
+ `PyTado.factory.TadoClientInitializer` is deprecated since 1.0.1 and will be removed in 2.0. Use
169
+ `PyTado.interface.Tado` instead.
170
+
146
171
  Note: For developers, there is an `example.py` script in `examples/` which is configured to fetch data from your account.
147
172
  You can then invoke `python examples/example.py`.
148
173
 
@@ -4,7 +4,7 @@ build-backend = "poetry.core.masonry.api"
4
4
 
5
5
  [tool.poetry]
6
6
  name = "python-tado"
7
- version = "1.0.1rc1"
7
+ version = "1.0.1rc2"
8
8
  description = "PyTado from chrism0dwk, modified by w.malgadey, diplix, michaelarnauts, LenhartStephan, splifter, syssi, andersonshatch, Yippy, p0thi, Coffee2CodeNL, chiefdragon, FilBr, nikilase, albertomontesg, Moritz-Schmidt, palazzem"
9
9
  authors = [
10
10
  "Chris Jewell <chrism0dwk@gmail.com>",
File without changes
File without changes