Skip to content
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

Update Hydrawise from the legacy API to the new GraphQL API #106904

Merged
merged 2 commits into from
Apr 23, 2024

Conversation

thomaskistler
Copy link
Contributor

@thomaskistler thomaskistler commented Jan 2, 2024

Breaking change

This change is fully backwards compatible in terms of functionality. However,
users will have to reauthenticate.

Proposed change

Move the Hydrawise integration from the old legacy Hydrawise API to the new
GraphQL API. This change is fully backwards compatible but will unlock new
functionality going forward.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

@home-assistant
Copy link

home-assistant bot commented Jan 2, 2024

Hey there @dknowles2, @ptcryan, mind taking a look at this pull request as it has been labeled with an integration (hydrawise) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of hydrawise can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign hydrawise Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@thomaskistler thomaskistler marked this pull request as ready for review January 2, 2024 19:47
homeassistant/components/hydrawise/config_flow.py Outdated Show resolved Hide resolved
homeassistant/components/hydrawise/config_flow.py Outdated Show resolved Hide resolved
tests/components/hydrawise/test_switch.py Outdated Show resolved Hide resolved
homeassistant/components/hydrawise/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/hydrawise/__init__.py Outdated Show resolved Hide resolved
homeassistant/components/hydrawise/manifest.json Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft January 3, 2024 06:17
@home-assistant
Copy link

home-assistant bot commented Jan 3, 2024

Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍

Learn more about our pull request process.

@MartinHjelmare MartinHjelmare changed the title Update Hydrawise from the legacy API to the new GraphQL API. Update Hydrawise from the legacy API to the new GraphQL API Jan 3, 2024
@thomaskistler thomaskistler mentioned this pull request Jan 4, 2024
20 tasks
@thomaskistler thomaskistler marked this pull request as ready for review January 4, 2024 03:21
@home-assistant home-assistant bot requested a review from joostlek January 4, 2024 03:21
@thomaskistler
Copy link
Contributor Author

Still waiting for review after addressing all reviewer comments.

@thomaskistler
Copy link
Contributor Author

Still waiting for a review. There are a number of issues that are batched up behind this PR. Would be nice to get it out of the way.

Copy link
Contributor

@dknowles2 dknowles2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only a minor nit. Otherwise LGTM.

(I don't have commit permissions though, so we'll need @joostlek approval)

@dknowles2
Copy link
Contributor

Ping?

@thomaskistler
Copy link
Contributor Author

I rebased it.

@dknowles2
Copy link
Contributor

@joostlek ping? This has been open since January. What's missing to get this merged? We have more changes we'd like to make that are blocked on this.

@joostlek
Copy link
Member

Mostly the fact that I am currently spending more time on my thesis so I have less time reviewing, but I'll try to find some time soon to take a look at it

@smenzer
Copy link

smenzer commented Apr 12, 2024

adding a +1 to get this reviewed so other features can be unblocked

homeassistant/components/hydrawise/config_flow.py Outdated Show resolved Hide resolved
Comment on lines 34 to 31
api_key: str | None = None,
username: str | None = None,
password: str | None = None,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does this method have default values for its parameters?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is called from two different places. It's either called with just the api_key or the username and password.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I see that, I'm just not a big fan of default values in cases like this.
I guess it's a matter of personal taste and it's OK like this.

# re-authenticate.
return self.async_create_entry(
title="Hydrawise",
data={CONF_API_KEY: api_key}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we import the API key?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you elaborate? This is the legacy path for old-style yaml files that contain the api key.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this PR, the only reference to CONF_API_KEY, outside tests and the config flow itself, is in async_setup_entry. With the changes in this PR, there's no longer any reference left to CONF_API_KEY, outside tests and the config flow itself, instead, async_setup_entry checks for the absence of username + password.

I guess we still want to store the API key for backwards compatibility though?

homeassistant/components/hydrawise/config_flow.py Outdated Show resolved Hide resolved
@home-assistant home-assistant bot marked this pull request as draft April 17, 2024 14:14
Copy link

@home-assistant home-assistant bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @thomaskistler,

When attempting to inspect the commits of your pull request for CLA signature status among all authors we encountered commit(s) which were not linked to a GitHub account, thus not allowing us to determine their status(es).

The commits that are missing a linked GitHub account are the following:

Unfortunately, we are unable to accept this pull request until this situation is corrected.

Here are your options:

  1. If you had an email address set for the commit that simply wasn't linked to your GitHub account you can link that email now and it will retroactively apply to your commits. The simplest way to do this is to click the link to one of the above commits and look for a blue question mark in a blue circle in the top left. Hovering over that bubble will show you what email address you used. Clicking on that button will take you to your email address settings on GitHub. Just add the email address on that page and you're all set. GitHub has more information about this option in their help center.

  2. If you didn't use an email address at all, it was an invalid email, or it's one you can't link to your GitHub, you will need to change the authorship information of the commit and your global Git settings so this doesn't happen again going forward. GitHub provides some great instructions on how to change your authorship information in their help center.

    • If you only made a single commit you should be able to run
      git commit --amend --author="Author Name <email@address.com>"
      
      (substituting "Author Name" and "email@address.com" for your actual information) to set the authorship information.
    • If you made more than one commit and the commit with the missing authorship information is not the most recent one you have two options:
      1. You can re-create all commits missing authorship information. This is going to be the easiest solution for developers that aren't extremely confident in their Git and command line skills.
      2. You can use this script that GitHub provides to rewrite history. Please note: this should be used only if you are very confident in your abilities and understand its impacts.
    • Whichever method you choose, I will come by to re-check the pull request once you push the fixes to this branch.

We apologize for this inconvenience, especially since it usually bites new contributors to Home Assistant. We hope you understand the need for us to protect ourselves and the great community we all have built legally. The best thing to come out of this is that you only need to fix this once and it benefits the entire Home Assistant and GitHub community.

Thanks, I look forward to checking this PR again soon! ❤️

result = await self._create_entry(
import_data.get(CONF_API_KEY, ""),
result = await self._create_or_update_entry(
api_key=import_data.get(CONF_API_KEY, ""),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not correct to use dict.get here since configuring an API token is mandatory in the YAML schema.

Suggested change
api_key=import_data.get(CONF_API_KEY, ""),
api_key=import_data[CONF_API_KEY],

@home-assistant home-assistant bot marked this pull request as draft April 22, 2024 07:42
@emontnemery
Copy link
Contributor

According to issue description, the hydrawise import flow was scheduled for removal in Home Assistant Core 2024.4. I think it would be a good idea to remove the import flow first, and then rebase this PR after that's done since it would simplify this PR significantly.

@dknowles2
Copy link
Contributor

According to issue description, the hydrawise import flow was scheduled for removal in Home Assistant Core 2024.4. I think it would be a good idea to remove the import flow first, and then rebase this PR after that's done since it would simplify this PR significantly.

My, how time flies!

#115966

@dknowles2
Copy link
Contributor

According to issue description, the hydrawise import flow was scheduled for removal in Home Assistant Core 2024.4. I think it would be a good idea to remove the import flow first, and then rebase this PR after that's done since it would simplify this PR significantly.

My, how time flies!

#115966

@thomaskistler you should be good to rebase now. The old YAML support code was removed in #115966, which has been merged.

@thomaskistler
Copy link
Contributor Author

I rebased everything.

@thomaskistler thomaskistler marked this pull request as ready for review April 23, 2024 04:34
Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @thomaskistler 👍

@emontnemery emontnemery merged commit b8f44fb into home-assistant:dev Apr 23, 2024
24 checks passed
tr4nt0r pushed a commit to tr4nt0r/ha-core that referenced this pull request Apr 23, 2024
…istant#106904)

* Update Hydrawise from the legacy API to the new GraphQL API.

* Cleanup
@github-actions github-actions bot locked and limited conversation to collaborators Apr 24, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants