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

Add basic support for HomeWizard v2 API configuration flow #135414

Conversation

DCSBL
Copy link
Contributor

@DCSBL DCSBL commented Jan 11, 2025

Proposed change

This API allows the user to configure the device via the v2 API. This API is now using a authorization step similar to Hue, where the user has to proof the possession by pressing the button on the device. Therefore the config flow has to be adjusted.

To keep this PR a bit concise, I didn't implement reauthorization, extensive error handling and migration. This will be done in follow-up PR's if that is okay.

You can test this with real hardware, ask me via a DM on discord for instructions.

Waits for #135315
Waits for #135778

Next steps:

  • Add support for Zeroconf // v2
  • Init integration via v2 API (which actually uses the new API)
  • Add reconfiguration flow for revoked token (happens when device is reset)
  • Add repair for devices that have v2 support but are not v2 configured (missing a token)
  • In the very future; WebSocket support for v2

⚠️ Will be merged in to itermediate-homewizard-v2-branch, which will be a collection of v2-support PR's.

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.

To help with the load of incoming pull requests:

@DCSBL DCSBL force-pushed the homewizard-user-v2-support branch from daf66e3 to 549b3fc Compare January 13, 2025 12:58
@DCSBL DCSBL marked this pull request as ready for review January 13, 2025 13:23
tests/components/homewizard/fixtures/v2/HWE-P1/device.json Outdated Show resolved Hide resolved
@@ -65,6 +72,59 @@ def mock_homewizardenergy(
yield client


@pytest.fixture
def mock_homewizardenergy_v2(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This feels dirty, if you have ideas/examples how to improve this let me know!

@DCSBL DCSBL marked this pull request as draft January 16, 2025 14:33
@DCSBL DCSBL marked this pull request as ready for review January 16, 2025 14:58
homeassistant/components/homewizard/config_flow.py Outdated Show resolved Hide resolved
Comment on lines 101 to 103
# Tell device we want a token, user must now press the button within 30 seconds
with contextlib.suppress(DisabledError):
token = await api.get_token("home-assistant")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@DCSBL DCSBL marked this pull request as ready for review January 19, 2025 19:26
@home-assistant home-assistant bot requested a review from joostlek January 19, 2025 19:27
@DCSBL DCSBL marked this pull request as draft January 19, 2025 19:54
@DCSBL DCSBL marked this pull request as ready for review January 19, 2025 20:06
@DCSBL
Copy link
Contributor Author

DCSBL commented Jan 22, 2025

@joostlek, I think I’ve processed all the feedback and got the docs ready. Do you mind to take a look at this one again?

@home-assistant home-assistant bot marked this pull request as draft January 22, 2025 20:44
@frenck frenck changed the base branch from dev to intermediate-homewizard-v2-api January 23, 2025 10:04
@DCSBL DCSBL marked this pull request as ready for review January 23, 2025 10:19
@home-assistant home-assistant bot requested a review from frenck January 23, 2025 10:19
Copy link
Member

@frenck frenck left a comment

Choose a reason for hiding this comment

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

Thanks, @DCSBL 👍

../Frenck

@frenck frenck dismissed joostlek’s stale review January 23, 2025 13:09

Comments addressed

@frenck frenck merged commit 13835b7 into home-assistant:intermediate-homewizard-v2-api Jan 23, 2025
32 checks passed
@DCSBL DCSBL deleted the homewizard-user-v2-support branch January 23, 2025 13:10
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2025
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.

3 participants