python-tado 0.19.5__tar.gz → 1.0.1rc1__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 (57) hide show
  1. {python_tado-0.19.5 → python_tado-1.0.1rc1}/PKG-INFO +25 -26
  2. python_tado-1.0.1rc1/PyTado/__init__.py +6 -0
  3. {python_tado-0.19.5 → python_tado-1.0.1rc1}/PyTado/__main__.py +15 -9
  4. python_tado-1.0.1rc1/PyTado/const.py +72 -0
  5. {python_tado-0.19.5 → python_tado-1.0.1rc1}/PyTado/exceptions.py +4 -0
  6. python_tado-1.0.1rc1/PyTado/factory/__init__.py +7 -0
  7. python_tado-1.0.1rc1/PyTado/factory/initializer.py +102 -0
  8. python_tado-1.0.1rc1/PyTado/http.py +832 -0
  9. {python_tado-0.19.5 → python_tado-1.0.1rc1}/PyTado/interface/api/__init__.py +2 -1
  10. python_tado-1.0.1rc1/PyTado/interface/api/base_tado.py +611 -0
  11. python_tado-1.0.1rc1/PyTado/interface/api/hops_tado.py +424 -0
  12. python_tado-1.0.1rc1/PyTado/interface/api/my_tado.py +364 -0
  13. python_tado-1.0.1rc1/PyTado/interface/interface.py +181 -0
  14. {python_tado-0.19.5 → python_tado-1.0.1rc1}/PyTado/logger.py +1 -1
  15. python_tado-1.0.1rc1/PyTado/models/__init__.py +8 -0
  16. python_tado-1.0.1rc1/PyTado/models/common/schedule.py +52 -0
  17. python_tado-1.0.1rc1/PyTado/models/historic.py +137 -0
  18. python_tado-1.0.1rc1/PyTado/models/home.py +206 -0
  19. python_tado-1.0.1rc1/PyTado/models/line_x/__init__.py +14 -0
  20. python_tado-1.0.1rc1/PyTado/models/line_x/device.py +62 -0
  21. python_tado-1.0.1rc1/PyTado/models/line_x/installation.py +8 -0
  22. python_tado-1.0.1rc1/PyTado/models/line_x/room.py +90 -0
  23. python_tado-1.0.1rc1/PyTado/models/line_x/schedule.py +31 -0
  24. python_tado-1.0.1rc1/PyTado/models/pre_line_x/__init__.py +23 -0
  25. python_tado-1.0.1rc1/PyTado/models/pre_line_x/boiler.py +36 -0
  26. python_tado-1.0.1rc1/PyTado/models/pre_line_x/device.py +42 -0
  27. python_tado-1.0.1rc1/PyTado/models/pre_line_x/flow_temperature_optimization.py +34 -0
  28. python_tado-1.0.1rc1/PyTado/models/pre_line_x/home.py +7 -0
  29. python_tado-1.0.1rc1/PyTado/models/pre_line_x/schedule.py +17 -0
  30. python_tado-1.0.1rc1/PyTado/models/pre_line_x/zone.py +288 -0
  31. python_tado-1.0.1rc1/PyTado/models/return_models.py +28 -0
  32. python_tado-1.0.1rc1/PyTado/models/util.py +93 -0
  33. python_tado-1.0.1rc1/PyTado/token_manager/__init__.py +15 -0
  34. python_tado-1.0.1rc1/PyTado/token_manager/can_manage_device_activation.py +35 -0
  35. python_tado-1.0.1rc1/PyTado/token_manager/device_token_manager.py +177 -0
  36. python_tado-1.0.1rc1/PyTado/token_manager/dummy_device_manager.py +21 -0
  37. python_tado-1.0.1rc1/PyTado/token_manager/file_token_manager.py +105 -0
  38. python_tado-1.0.1rc1/PyTado/token_manager/token_manager_interface.py +20 -0
  39. python_tado-1.0.1rc1/PyTado/types.py +207 -0
  40. python_tado-1.0.1rc1/PyTado/zone/__init__.py +6 -0
  41. python_tado-1.0.1rc1/PyTado/zone/base_zone.py +471 -0
  42. python_tado-1.0.1rc1/PyTado/zone/hops_zone.py +360 -0
  43. python_tado-1.0.1rc1/PyTado/zone/my_zone.py +506 -0
  44. {python_tado-0.19.5 → python_tado-1.0.1rc1}/README.md +21 -23
  45. {python_tado-0.19.5 → python_tado-1.0.1rc1}/pyproject.toml +22 -12
  46. python_tado-0.19.5/PyTado/const.py +0 -99
  47. python_tado-0.19.5/PyTado/http.py +0 -594
  48. python_tado-0.19.5/PyTado/interface/api/hops_tado.py +0 -376
  49. python_tado-0.19.5/PyTado/interface/api/my_tado.py +0 -623
  50. python_tado-0.19.5/PyTado/interface/interface.py +0 -365
  51. python_tado-0.19.5/PyTado/zone/__init__.py +0 -6
  52. python_tado-0.19.5/PyTado/zone/hops_zone.py +0 -132
  53. python_tado-0.19.5/PyTado/zone/my_zone.py +0 -215
  54. {python_tado-0.19.5 → python_tado-1.0.1rc1}/AUTHORS +0 -0
  55. {python_tado-0.19.5 → python_tado-1.0.1rc1}/LICENSE +0 -0
  56. {python_tado-0.19.5 → python_tado-1.0.1rc1}/PyTado/interface/__init__.py +0 -0
  57. {python_tado-0.19.5/PyTado → python_tado-1.0.1rc1/PyTado/models/common}/__init__.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python-tado
3
- Version: 0.19.5
3
+ Version: 1.0.1rc1
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
@@ -9,7 +9,7 @@ Keywords: tado
9
9
  Author: Chris Jewell
10
10
  Author-email: chrism0dwk@gmail.com
11
11
  Requires-Python: >=3.11
12
- Classifier: Development Status :: 4 - Beta
12
+ Classifier: Development Status :: 5 - Production/Stable
13
13
  Classifier: Intended Audience :: Developers
14
14
  Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
15
15
  Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
@@ -25,8 +25,9 @@ Provides-Extra: all
25
25
  Provides-Extra: dev
26
26
  Provides-Extra: lint
27
27
  Provides-Extra: test
28
- Requires-Dist: black (>=24.10) ; extra == "lint" or extra == "all"
29
28
  Requires-Dist: pre-commit ; extra == "dev" or extra == "all"
29
+ Requires-Dist: pydantic (>=2.10.6,<3.0.0)
30
+ Requires-Dist: pydoc-markdown ; extra == "dev" or extra == "all"
30
31
  Requires-Dist: pylint ; extra == "lint" or extra == "all"
31
32
  Requires-Dist: pytest ; extra == "test" or extra == "all"
32
33
  Requires-Dist: pytest-cov ; extra == "test" or extra == "all"
@@ -55,14 +56,14 @@ PyTado is a Python module implementing an interface to the Tado web API. It allo
55
56
  Tado heating system for the purposes of monitoring or controlling their heating system, beyond what Tado themselves
56
57
  currently offer.
57
58
 
58
- It is hoped that this module might be used by those who wish to tweak their Tado systems, and further optimise their
59
+ It is hoped that this module might be used by those who wish to tweak their Tado systems, and further optimize their
59
60
  heating setups.
60
61
 
61
62
  ---
62
63
 
63
64
  Original author: Chris Jewell <chrism0dwk@gmail.com>
64
65
 
65
- Licence: GPL v3
66
+ License: GPL v3
66
67
 
67
68
  Copyright: Chris Jewell 2016-2018
68
69
 
@@ -71,7 +72,7 @@ Copyright: Chris Jewell 2016-2018
71
72
  Besides owning a Tado system, I have no connection with the Tado company themselves. PyTado was created for my own use,
72
73
  and for others who may wish to experiment with personal Internet of Things systems. I receive no help (financial or
73
74
  otherwise) from Tado, and have no business interest with them. This software is provided without warranty, according to
74
- the GNU Public Licence version 3, and should therefore not be used where it may endanger life, financial stakes, or
75
+ the GNU Public License version 3, and should therefore not be used where it may endanger life, financial stakes, or
75
76
  cause discomfort and inconvenience to others.
76
77
 
77
78
  ## Versions
@@ -88,12 +89,10 @@ Pin the line you need, e.g. `python-tado~=0.18.17` for the old API or `python-ta
88
89
 
89
90
  ### Releases to avoid
90
91
 
91
- - **0.19.4** contains the 1.x API by mistake, even though its version number says 0.19. It is being yanked on PyPI (once 0.19.5 is out). Use 0.19.5 (old API) or 1.0.1 or later (new API) instead.
92
+ - **0.19.4** contains the 1.x API by mistake, even though its version number says 0.19. It is yanked on PyPI (since 2026-11-30). Use 0.19.5 (old API) or 1.0.1 or later (new API) instead.
92
93
  - **1.0.0** was uploaded to PyPI by mistake (from the 0.19.3 tag) and then deleted. PyPI never accepts a version number twice, so the first stable 1.x release is **1.0.1**.
93
94
  - **0.19.3** was never published to PyPI.
94
95
 
95
- **You are looking at 0.19.5**: the old API, identical to 0.19.2. For new projects use 1.x; for the old API prefer 0.18.x, which gets fixes.
96
-
97
96
  Release notes for every version are on the [GitHub releases page](https://github.com/wmalgadey/PyTado/releases).
98
97
 
99
98
  ## Usage
@@ -121,7 +120,7 @@ It is possible to save the refresh token and reuse to skip the next login.
121
120
 
122
121
  The following code will use the `refresh_token` file to save the refresh-token after login, and load the refresh-token if you create the Tado interface class again.
123
122
 
124
- If the file doesn't exists, the webbrowser is started and the device authentication url is automatically opened. You can activate the device in the browser. When you restart the program, the refresh-token is reused and no webbrowser will be opened.
123
+ If the file doesn't exists, the web browser is started and the device authentication url is automatically opened. You can activate the device in the browser. When you restart the program, the refresh-token is reused and no web browser will be opened.
125
124
 
126
125
  ```python
127
126
  import webbrowser # only needed for direct web browser access
@@ -147,6 +146,21 @@ else:
147
146
  print(f"Login status is {status}")
148
147
  ```
149
148
 
149
+ ### Sharing the login between several processes
150
+
151
+ If several processes on one machine use PyTado (e.g. a service and a CLI), use the
152
+ `DeviceTokenManager`. It stores the refresh token in a per-user data directory (or in
153
+ `data_dir`) and shares a running device activation: the processes show the same code
154
+ instead of each asking tado for a new one, and they pick up the token once one of them
155
+ is activated.
156
+
157
+ ```python
158
+ from PyTado.interface.interface import Tado
159
+ from PyTado.token_manager import DeviceTokenManager
160
+
161
+ tado = Tado(token_manager=DeviceTokenManager())
162
+ ```
163
+
150
164
  ## Example code
151
165
 
152
166
  ```python
@@ -178,7 +192,6 @@ if __name__ == "__main__":
178
192
  Note: For developers, there is an `example.py` script in `examples/` which is configured to fetch data from your account.
179
193
  You can then invoke `python examples/example.py`.
180
194
 
181
-
182
195
  ## Contributing
183
196
 
184
197
  We are very open to the community's contributions - be it a quick fix of a typo, or a completely new feature!
@@ -210,20 +223,7 @@ git clone https://github.com/yourusername/PyTado.git
210
223
  cd PyTado
211
224
  ```
212
225
 
213
- Then, to create your development environment and install the project with its dependencies, execute the following
214
- commands in your terminal:
215
-
216
- ```bash
217
- # Create and activate a new virtual environment
218
- python3 -m venv venv
219
- source venv/bin/activate
220
-
221
- # install all dependencies
222
- poetry install
223
-
224
- # Install pre-commit hooks
225
- poetry run pre-commit install
226
- ```
226
+ Then, to create your development environment and install the project with its dependencies, execute the `./scripts/bootstrap` script.
227
227
 
228
228
  ### Coding Guidelines
229
229
 
@@ -262,7 +262,6 @@ A message from the original author:
262
262
  >
263
263
  > Chris Jewell
264
264
 
265
-
266
265
  [devcontainer-shield]: https://img.shields.io/static/v1?label=Dev%20Containers&message=Open&color=blue&logo=visualstudiocode
267
266
  [devcontainer]: https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/wmalgadey/PyTado
268
267
 
@@ -0,0 +1,6 @@
1
+ from importlib.metadata import PackageNotFoundError, version
2
+
3
+ try:
4
+ __version__ = version("python-tado")
5
+ except PackageNotFoundError:
6
+ __version__ = "test" # happens when running as pre-commit hook
@@ -9,7 +9,7 @@ import sys
9
9
  from PyTado.interface import Tado
10
10
 
11
11
 
12
- def log_in(args):
12
+ def log_in(args: argparse.Namespace) -> Tado:
13
13
  """
14
14
  Log in to the Tado API by activating the current device.
15
15
 
@@ -27,7 +27,7 @@ def log_in(args):
27
27
  return t
28
28
 
29
29
 
30
- def get_me(args):
30
+ def get_me(args: argparse.Namespace) -> None:
31
31
  """
32
32
  Retrieve and print home information from the Tado API.
33
33
 
@@ -39,7 +39,7 @@ def get_me(args):
39
39
  print(me)
40
40
 
41
41
 
42
- def get_state(args):
42
+ def get_state(args: argparse.Namespace) -> None:
43
43
  """
44
44
  Retrieve and print the state of a specific zone from the Tado API.
45
45
 
@@ -51,7 +51,7 @@ def get_state(args):
51
51
  print(zone)
52
52
 
53
53
 
54
- def get_states(args):
54
+ def get_states(args: argparse.Namespace) -> None:
55
55
  """
56
56
  Retrieve and print the states of all zones from the Tado API.
57
57
 
@@ -63,7 +63,7 @@ def get_states(args):
63
63
  print(zones)
64
64
 
65
65
 
66
- def get_capabilities(args):
66
+ def get_capabilities(args: argparse.Namespace) -> None:
67
67
  """
68
68
  Retrieve and print the capabilities of a specific zone from the Tado API.
69
69
 
@@ -75,7 +75,7 @@ def get_capabilities(args):
75
75
  print(capabilities)
76
76
 
77
77
 
78
- def main():
78
+ def main() -> None:
79
79
  """
80
80
  Main method for the script.
81
81
 
@@ -109,17 +109,23 @@ def main():
109
109
  show_config_parser = subparsers.add_parser("get_me", help="Get home information.")
110
110
  show_config_parser.set_defaults(func=get_me)
111
111
 
112
- start_activity_parser = subparsers.add_parser("get_state", help="Get state of zone.")
112
+ start_activity_parser = subparsers.add_parser(
113
+ "get_state", help="Get state of zone."
114
+ )
113
115
  start_activity_parser.add_argument("--zone", help="Zone to get the state of.")
114
116
  start_activity_parser.set_defaults(func=get_state)
115
117
 
116
- start_activity_parser = subparsers.add_parser("get_states", help="Get states of all zones.")
118
+ start_activity_parser = subparsers.add_parser(
119
+ "get_states", help="Get states of all zones."
120
+ )
117
121
  start_activity_parser.set_defaults(func=get_states)
118
122
 
119
123
  start_activity_parser = subparsers.add_parser(
120
124
  "get_capabilities", help="Get capabilities of zone."
121
125
  )
122
- start_activity_parser.add_argument("--zone", help="Zone to get the capabilities of.")
126
+ start_activity_parser.add_argument(
127
+ "--zone", help="Zone to get the capabilities of."
128
+ )
123
129
  start_activity_parser.set_defaults(func=get_capabilities)
124
130
 
125
131
  args = parser.parse_args()
@@ -0,0 +1,72 @@
1
+ """Constant values for the Tado component."""
2
+
3
+ from PyTado.types import FanLevel, FanSpeed, HvacAction, HvacMode
4
+
5
+ # API client ID
6
+ CLIENT_ID_DEVICE = "1bb50063-6b0c-4d11-bd99-387f4a91cc46" # nosec B105
7
+
8
+
9
+ CONST_LINK_OFFLINE = "OFFLINE"
10
+ CONST_CONNECTION_OFFLINE = "OFFLINE"
11
+
12
+
13
+ FAN_SPEED_TO_FAN_LEVEL = {
14
+ FanSpeed.OFF: FanLevel.OFF,
15
+ FanSpeed.AUTO: FanLevel.AUTO,
16
+ FanSpeed.LOW: FanLevel.LEVEL1,
17
+ FanSpeed.MIDDLE: FanLevel.LEVEL2,
18
+ FanSpeed.HIGH: FanLevel.LEVEL3,
19
+ }
20
+
21
+ # When we change the temperature setting, we need an overlay mode
22
+ CONST_OVERLAY_TADO_MODE = (
23
+ "NEXT_TIME_BLOCK" # wait until tado changes the mode automatic
24
+ )
25
+ CONST_OVERLAY_MANUAL = "MANUAL" # the user has changed the temperature or mode manually
26
+ CONST_OVERLAY_TIMER = "TIMER" # the temperature will be reset after a timespan
27
+
28
+ # Heat always comes first since we get the
29
+ # min and max tempatures for the zone from
30
+ # it.
31
+ # Heat is preferred as it generally has a lower minimum temperature
32
+ ORDERED_KNOWN_TADO_MODES = [
33
+ HvacMode.HEAT,
34
+ HvacMode.COOL,
35
+ HvacMode.AUTO,
36
+ HvacMode.DRY,
37
+ HvacMode.FAN,
38
+ ]
39
+
40
+ TADO_MODES_TO_HVAC_ACTION: dict[HvacMode, HvacAction] = {
41
+ HvacMode.HEAT: HvacAction.HEATING,
42
+ HvacMode.DRY: HvacAction.DRYING,
43
+ HvacMode.FAN: HvacAction.FAN,
44
+ HvacMode.COOL: HvacAction.COOLING,
45
+ }
46
+
47
+ TADO_HVAC_ACTION_TO_MODES: dict[HvacAction, HvacMode | HvacAction] = {
48
+ HvacAction.HEATING: HvacMode.HEAT,
49
+ HvacAction.HOT_WATER: HvacAction.HEATING,
50
+ HvacAction.DRYING: HvacMode.DRY,
51
+ HvacAction.FAN: HvacMode.FAN,
52
+ HvacAction.COOLING: HvacMode.COOL,
53
+ }
54
+
55
+ # These modes will not allow a temp to be set
56
+ TADO_MODES_WITH_NO_TEMP_SETTING = [
57
+ HvacMode.AUTO,
58
+ HvacMode.DRY,
59
+ HvacMode.FAN,
60
+ ]
61
+
62
+ DEFAULT_TADO_PRECISION = 0.1
63
+ DEFAULT_TADOX_PRECISION = 0.01
64
+ DEFAULT_DATE_FORMAT = "%Y-%m-%d"
65
+
66
+ DEFAULT_TADOX_MIN_TEMP = 5.0
67
+ DEFAULT_TADOX_MAX_TEMP = 30.0
68
+
69
+ HOME_DOMAIN = "homes"
70
+ DEVICE_DOMAIN = "devices"
71
+
72
+ HTTP_CODES_OK = [200, 201, 202, 204]
@@ -19,3 +19,7 @@ class TadoNoCredentialsException(TadoCredentialsException):
19
19
 
20
20
  class TadoWrongCredentialsException(TadoCredentialsException):
21
21
  """Exception to indicate wrong credentials"""
22
+
23
+
24
+ class TadoRateLimitException(TadoException):
25
+ """Exception to indicate API rate limit has been exceeded."""
@@ -0,0 +1,7 @@
1
+ """Factory method for easy initialization."""
2
+
3
+ from ..interface.api.hops_tado import TadoX
4
+ from ..interface.api.my_tado import Tado
5
+ from .initializer import TadoClientInitializer
6
+
7
+ __all__ = ["Tado", "TadoX", "TadoClientInitializer"]
@@ -0,0 +1,102 @@
1
+ """
2
+ PyTado API factory to use app.tado.com or hops.tado.com
3
+ """
4
+
5
+ from typing import Callable, Self
6
+
7
+ import requests
8
+
9
+ import PyTado.interface.api as API
10
+ from PyTado.exceptions import TadoException
11
+ from PyTado.http import DeviceActivationStatus, Http
12
+ from PyTado.token_manager import TokenManagerInterface
13
+
14
+
15
+ class TadoClientInitializer:
16
+ """Class to authenticate and get the Tado client."""
17
+
18
+ http: Http
19
+ debug: bool = False
20
+ token_file_path: str | None = None
21
+ saved_refresh_token: str | None = None
22
+ http_session: requests.Session | None = None
23
+
24
+ def __init__(
25
+ self,
26
+ token_file_path: str | None = None,
27
+ saved_refresh_token: str | None = None,
28
+ http_session: requests.Session | None = None,
29
+ debug: bool = False,
30
+ user_agent: str | None = None,
31
+ client_id: str | None = None,
32
+ token_update_callback: Callable[[str], None] | None = None,
33
+ token_manager: TokenManagerInterface | None = None,
34
+ ):
35
+ """Takes the same login options as PyTado.interface.Tado."""
36
+ self.token_file_path = token_file_path
37
+ self.saved_refresh_token = saved_refresh_token
38
+ self.http_session = http_session
39
+ self.debug = debug
40
+ self.http = Http(
41
+ token_file_path=token_file_path,
42
+ saved_refresh_token=saved_refresh_token,
43
+ http_session=http_session,
44
+ debug=debug,
45
+ user_agent=user_agent,
46
+ client_id=client_id,
47
+ token_update_callback=token_update_callback,
48
+ token_manager=token_manager,
49
+ )
50
+
51
+ def get_verification_url(self) -> str | None:
52
+ """Returns the URL for device verification."""
53
+ if self.http.device_activation_status == DeviceActivationStatus.NOT_STARTED:
54
+ self.device_activation()
55
+
56
+ return self.http.device_verification_url
57
+
58
+ def device_activation(self) -> Self:
59
+ """Activates the device.
60
+
61
+ Caution: this method will block until the device is activated or the timeout is reached.
62
+ """
63
+ self.http.device_activation()
64
+
65
+ return self
66
+
67
+ def get_client(self) -> API.TadoX | API.Tado:
68
+ """Returns the client instance after device activation."""
69
+ if self.http.device_activation_status == DeviceActivationStatus.COMPLETED:
70
+ if self.http.is_x_line:
71
+ return API.TadoX.from_http(http=self.http, debug=self.debug)
72
+
73
+ return API.Tado.from_http(http=self.http, debug=self.debug)
74
+
75
+ raise TadoException(
76
+ "Authentication failed. Please check the device verification URL and try again."
77
+ )
78
+
79
+ def authenticate_and_get_client(self) -> API.TadoX | API.Tado:
80
+ """Authenticate and get the client instance, prompting for device activation if needed."""
81
+ print("Starting device activation process...")
82
+ print("Device activation status: ", self.http.device_activation_status)
83
+
84
+ if self.http.device_activation_status != DeviceActivationStatus.COMPLETED:
85
+ print("Click on the link to log in to your Tado account.")
86
+ print("Device verification URL: ", self.get_verification_url())
87
+
88
+ self.device_activation()
89
+
90
+ # device_activation() changes the status; mypy narrows it too eagerly
91
+ if (
92
+ self.http.device_activation_status # type: ignore[comparison-overlap]
93
+ == DeviceActivationStatus.COMPLETED
94
+ ): # pyright: ignore[reportUnnecessaryComparison]
95
+ print("Device activation completed successfully.")
96
+ else:
97
+ raise TadoException(
98
+ "Device activation failed. "
99
+ "Please check the device verification URL and try again."
100
+ )
101
+
102
+ return self.get_client()