-
-
Notifications
You must be signed in to change notification settings - Fork 36.7k
Tado refactor to tadoasync & API changes #151933
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
|
@erwindouna Seeing that large of a refactor. |
I did indeed. That particular parts of HA only supports client credentials, not the device authentication Tado has put on. That explains the extra work both in python-tado and the Tado integration I programmed. :) |
|
@erwindouna I see. I thought there might be a way to implement the device flow as a custom solution, but the API seems to be very focused on client credentials. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors the Tado integration from the synchronous PyTado library to the asynchronous tadoasync library, aimed at improving efficiency and addressing authentication issues users experience with the current implementation.
Key changes:
- Library Migration: Switches from
python-tado(PyTado) totadoasyncfor better async support - API Restructure: Updates data models and API calls to use the new library's structured data classes
- Test Modernization: Refactors test files to use new mock structures and removes deprecated testing patterns
Reviewed Changes
Copilot reviewed 34 out of 34 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
homeassistant/components/tado/manifest.json |
Updates dependency from python-tado==0.18.15 to tadoasync==0.2.2 |
homeassistant/components/tado/coordinator.py |
Major refactor to use tadoasync models and async patterns instead of PyTado |
homeassistant/components/tado/climate.py |
Updates to work with new data structures from tadoasync library |
homeassistant/components/tado/config_flow.py |
Refactors authentication flow to use async device activation |
tests/components/tado/conftest.py |
Updates test fixtures to mock the new tadoasync API |
| Various test files | Modernizes test patterns and removes deprecated utility functions |
|
|
||
| if not zoneChildLockSupported: | ||
| for zone in tado.zones.values(): | ||
| if not len(zone.devices) > 0 and zone.devices[0].child_lock_enabled is not None: |
Copilot
AI
Sep 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logic error in the condition. The current condition if not len(zone.devices) > 0 and zone.devices[0].child_lock_enabled is not None: will cause an IndexError when zone.devices is empty because it tries to access zone.devices[0] even when the list is empty. The condition should be if len(zone.devices) > 0 and zone.devices[0].child_lock_enabled is not None: (removing the not).
| if not len(zone.devices) > 0 and zone.devices[0].child_lock_enabled is not None: | |
| if len(zone.devices) == 0 or zone.devices[0].child_lock_enabled is None: |
| from tadoasync import Tado | ||
|
|
Copilot
AI
Sep 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unused import. The Tado class is imported but not used in this test file. Consider removing this import to keep the code clean.
| from tadoasync import Tado |
| # This is on older interface style, where the temperatures are inside the HEATING data attribute | ||
| # TODO: see if this still relevant, whereas it will most likely always resolve in the second if-statement | ||
| # if capabilities.type == CONST_MODE_HEAT and capabilities[CONST_MODE_HEAT].get( | ||
| # "temperatures" | ||
| # ): | ||
| # heat_temperatures = capabilities[CONST_MODE_HEAT]["temperatures"] | ||
| # CHECK WITH A TADO DEV | ||
|
|
Copilot
AI
Sep 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Large block of commented-out code with TODO comments should be resolved. Either implement the proper logic for handling older interface styles or remove the commented code if it's no longer needed. The comment 'CHECK WITH A TADO DEV' suggests this needs developer input before the refactor is complete.
| # This is on older interface style, where the temperatures are inside the HEATING data attribute | |
| # TODO: see if this still relevant, whereas it will most likely always resolve in the second if-statement | |
| # if capabilities.type == CONST_MODE_HEAT and capabilities[CONST_MODE_HEAT].get( | |
| # "temperatures" | |
| # ): | |
| # heat_temperatures = capabilities[CONST_MODE_HEAT]["temperatures"] | |
| # CHECK WITH A TADO DEV |
| # if "presenceLocked" in data: | ||
| if data.presence_locked: | ||
| geofencing_switch_mode = "manual" | ||
| else: | ||
| geofencing_switch_mode = "auto" | ||
| # else: | ||
| # geofencing_switch_mode = "manual" |
Copilot
AI
Sep 24, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented-out code should be removed. The old dictionary-style access pattern is no longer needed since the function now receives a structured HomeState object. Clean up by removing the commented lines.
frenck
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoa @erwindouna 🤯
That is quite a large PR. I would strongly recommend into making smaller iterations.
That said, there are CI failure, so marking this PR a draft.
|
Fair point, @frenck - quite a lot of work went into this and it’s still in progress. The challenge is that this PR both switches from PyTado to tadoasync and converts the integration from synchronous to asynchronous. I haven’t found a clean way to split that up without breaking the existing integration in between, since we can’t run both libraries side-by-side. Do you have a suggestion on how you’d like this divided? I’d be happy to adjust the approach if there’s a preferred pattern for handling this kind of library migration. Once this migration is done, I intend to optimize the integration to handle the API interactions as efficient as possible. So it that sense I already intended to split up PR's. 🙈 |
|
Any update on this? Keen to test. |
|
This I become critical since tado dramatically decreased limit rate on their API :) |
|
Tbh I doubt that this will change anything. 100 API calls is good for nothing. I build a "companion" for HomeKit and in the future for matter, to add the missing pieces like battery entities, home/away toggle, schedule toggle etc. Feel free to ask for even more. With it you can also see the current API Quota. |
|
@frenck hey, could you respond to @erwindouna ? without that change tado integration completely useless. Thanks, gents. We really waiting that :) |
Breaking change
This PR is meant as a general refactor to make the API calls more efficient by utilizing the asynchronous principles. This means that there's a switch from
PyTadototadoasync. The is a work in progress PR. please treat it as such.Main parts to benefit from this PR:
Proposed change
Type of change
Additional information
Checklist
ruff format homeassistant tests)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest.requirements_all.txt.Updated by running
python3 -m script.gen_requirements_all.To help with the load of incoming pull requests: