-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
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
Use the new hybrid Hydrawise client #136522
Conversation
Hey there @thomaskistler, @ptcryan, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
@@ -63,7 +63,7 @@ def mock_pydrawise( | |||
controller_water_use_summary: ControllerWaterUseSummary, | |||
) -> Generator[AsyncMock]: | |||
"""Mock Hydrawise.""" | |||
with patch("pydrawise.client.Hydrawise", autospec=True) as mock_pydrawise: | |||
with patch("pydrawise.hybrid.HybridClient", autospec=True) as mock_pydrawise: |
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.
Can we start patching this where we use the objects? so homeassistant.components.hydrawise.....
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.
That's a big change because every test that uses the mock would need to do its own patching. (we import the pydrawise client in both __init__.py
and config_flow.py
)
Mind if I send a separate cleanup PR for that?
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.
Sure, but you can just create a way to mock both with the same mock. Check airgradient for example
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
Thanks for this. Will this be in the next core update? |
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
Breaking change
Hydrawise now requires an API key for authentication.
In order to alleviate API throttling issues, we now fall back on the REST API when polling for status updates. This requires an API key, which can be generated under the "Account Details" section of the Hydrawise app.
Proposed change
After a lot of back-and-forth with a Hydrawise Product Manager, we have determined that we cannot poll the newer GraphQL API for updates, as it's not able to handle the load. (See #130857 (comment) for a snippet of the conversation)
This PR changes the Hydrawise client to the new "hybrid" approach added in pydrawise 2025.1.0 (see dknowles2/pydrawise#257 for details). This new client hides the details of which API we need to use for fetching data, allowing Home Assistant to use the same client interface. This should be a drop-in replacement, except for now requiring an API key for authenticating with the REST API.
The transition should be relatively smooth for a user: we simply trigger a reauth flow if the user is missing an API key, after which the integration should continue working normally.
(Note: I haven't updated the docs yet, I'll do that soon)
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: