|
1 | 1 | """Asynchronous Python client for the Tado API. This is an example file.""" |
2 | 2 |
|
| 3 | +from __future__ import annotations |
| 4 | + |
3 | 5 | import asyncio |
| 6 | +import logging |
4 | 7 |
|
5 | 8 | from tadoasync import Tado |
6 | 9 |
|
| 10 | +logging.basicConfig(level=logging.DEBUG) |
| 11 | + |
7 | 12 |
|
8 | 13 | async def main() -> None: |
9 | 14 | """Show example on how to use aiohttp.ClientSession.""" |
10 | | - async with Tado("username", "password") as tado: |
11 | | - await tado.get_devices() |
| 15 | + refresh_token: str | None = None |
| 16 | + async with Tado(debug=True) as tado: |
| 17 | + print("Device activation status: ", tado.device_activation_status) # noqa: T201 |
| 18 | + print("Device verification URL: ", tado.device_verification_url) # noqa: T201 |
| 19 | + |
| 20 | + print("Starting device activation") # noqa: T201 |
| 21 | + await tado.device_activation() |
| 22 | + refresh_token = tado.refresh_token |
| 23 | + |
| 24 | + print("Device activation status: ", tado.device_activation_status) # noqa: T201 |
| 25 | + |
| 26 | + devices = await tado.get_devices() |
| 27 | + |
| 28 | + print("Devices: ", devices) # noqa: T201 |
| 29 | + |
| 30 | + print("Trying to use the stored refresh token for another run...") # noqa: T201 |
| 31 | + await asyncio.sleep(1) |
| 32 | + |
| 33 | + async with Tado(debug=True, refresh_token=refresh_token) as tado: |
| 34 | + print("Refresh token: ", tado.refresh_token) # noqa: T201 |
| 35 | + print("Device activation status: ", tado.device_activation_status) # noqa: T201 |
| 36 | + |
| 37 | + devices = await tado.get_devices() |
| 38 | + |
| 39 | + print("Devices: ", devices) # noqa: T201 |
12 | 40 |
|
13 | 41 |
|
14 | 42 | if __name__ == "__main__": |
|
0 commit comments