Skip to content

Add reconfiguration flow to Duco integration#168652

Open
ronaldvdmeer wants to merge 11 commits intohome-assistant:devfrom
ronaldvdmeer:add-duco-reconfigure-flow
Open

Add reconfiguration flow to Duco integration#168652
ronaldvdmeer wants to merge 11 commits intohome-assistant:devfrom
ronaldvdmeer:add-duco-reconfigure-flow

Conversation

@ronaldvdmeer
Copy link
Copy Markdown
Contributor

@ronaldvdmeer ronaldvdmeer commented Apr 20, 2026

Proposed change

Add a reconfiguration flow to the Duco integration so users can update the IP address or hostname of an already-configured Duco ventilation box without removing and re-adding the integration.

Changes:

  • async_step_reconfigure in the config flow
  • Aborts with unique_id_mismatch if the new host responds with a different MAC address
  • Translations for reconfigure_successful and unique_id_mismatch abort reasons and the reconfigure step
  • Tests covering success, unique-id-mismatch, and error paths
  • quality_scale.yaml: reconfiguration-flow: done, repair-issues: exempt

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

  • I understand the code I am submitting and can explain how it works.
  • 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.
  • Any generated code has been carefully reviewed for correctness and compliance with project standards.

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 diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

- Implement async_step_reconfigure method in config flow
- Allow users to change IP address of Duco device
- Validate device identity via MAC address to prevent configuration mixups
- Add comprehensive test coverage for success, error, and wrong device scenarios
- Update strings.json with reconfigure flow translations
- Mark reconfiguration-flow quality scale rule as done
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a reconfiguration flow to the Duco integration so an existing config entry’s host (IP/hostname) can be updated in-place while preventing accidental reassignment to a different device.

Changes:

  • Implement async_step_reconfigure in the Duco config flow, validating the target device via MAC and aborting on mismatch.
  • Add translation strings for the reconfigure step and new abort reasons (reconfigure_successful, wrong_device).
  • Add tests covering successful reconfigure, wrong-device abort, and connection/unknown error handling; update quality scale to mark reconfiguration-flow as done.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
homeassistant/components/duco/config_flow.py Adds reconfigure step to validate new host and update+reload entry, aborting if the MAC differs.
homeassistant/components/duco/strings.json Adds translations for reconfigure step and abort reasons.
homeassistant/components/duco/quality_scale.yaml Marks reconfiguration-flow as done.
tests/components/duco/test_config_flow.py Adds tests for the new reconfiguration behavior.

Comment thread tests/components/duco/test_config_flow.py
Comment thread homeassistant/components/duco/strings.json Outdated
Comment thread homeassistant/components/duco/config_flow.py Outdated
Comment thread tests/components/duco/test_config_flow.py
Prevents async_update_reload_and_abort from triggering the real
async_setup_entry during config flow tests via the scheduled reload.
Replace custom wrong_device abort reason with the standard
unique_id_mismatch by calling _abort_if_unique_id_mismatch()
without an explicit reason argument. Update strings.json and
test assertions accordingly.
Test that the flow correctly recovers from a connection error
and completes successfully on the next attempt.
Copilot AI review requested due to automatic review settings April 20, 2026 20:28
@ronaldvdmeer ronaldvdmeer marked this pull request as ready for review April 20, 2026 20:32
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds a reconfiguration flow to the Duco integration so an existing config entry’s host can be updated (with unique-id/mismatch protection), along with translations, tests, and quality scale updates.

Changes:

  • Implement async_step_reconfigure to update CONF_HOST and reload the config entry after validating the device identity.
  • Add config-flow translations for the reconfigure step and new abort reasons.
  • Add config-flow tests covering success, connection/unknown errors, and unique-id mismatch cases; update quality scale status.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
homeassistant/components/duco/config_flow.py Adds async_step_reconfigure that validates the new host, aborts on unique-id mismatch, and updates/reloads the entry.
homeassistant/components/duco/strings.json Adds translations for the reconfigure step and abort reasons used by the new flow.
tests/components/duco/test_config_flow.py Adds test coverage for the reconfiguration flow success and failure paths.
homeassistant/components/duco/quality_scale.yaml Marks reconfiguration-flow as done and sets repair-issues to exempt.

Comment thread homeassistant/components/duco/config_flow.py
Comment thread homeassistant/components/duco/config_flow.py Outdated
@home-assistant home-assistant bot marked this pull request as draft April 20, 2026 20:38
@home-assistant
Copy link
Copy Markdown

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.

Replace inline vol.Schema with default= with the standard
add_suggested_values_to_schema pattern, reusing the existing
STEP_USER_SCHEMA constant.
@ronaldvdmeer ronaldvdmeer marked this pull request as ready for review April 20, 2026 20:45
Copilot AI review requested due to automatic review settings April 20, 2026 20:45
@home-assistant home-assistant bot requested a review from erwindouna April 20, 2026 20:45
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 adds a reconfiguration flow to the Duco integration so an existing config entry’s host (IP/hostname) can be updated in-place while ensuring the user doesn’t accidentally point the entry at a different device.

Changes:

  • Add async_step_reconfigure to DucoConfigFlow that validates the new host and updates + reloads the config entry, aborting on unique-id mismatch.
  • Add config-flow translations for the new reconfigure step and abort reasons.
  • Add config flow tests for reconfigure success, unique-id mismatch, and error handling; update the integration quality scale status.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
homeassistant/components/duco/config_flow.py Implements the reconfigure step that validates the device MAC and updates/reloads the entry host.
homeassistant/components/duco/strings.json Adds UI strings for the reconfigure step and abort reasons used by the new flow.
homeassistant/components/duco/quality_scale.yaml Marks reconfiguration-flow as done and notes repair issues as exempt.
tests/components/duco/test_config_flow.py Adds tests covering the reconfigure flow paths (success, mismatch, errors).

Comment thread tests/components/duco/test_config_flow.py
Comment thread tests/components/duco/test_config_flow.py
Comment thread tests/components/duco/test_config_flow.py
@home-assistant home-assistant bot marked this pull request as draft April 20, 2026 20:54
The error and success steps previously both used '192.168.1.200',
making the test misleading. Using '192.168.1.50' for the failing
attempt makes it immediately clear that '192.168.1.200' is the
actual new host being configured on success.
Add async_block_till_done() after the final async_configure call so
the scheduled config entry reload triggered by async_update_reload_and_abort
is flushed before the assertions run.
Add async_block_till_done() after the final async_configure call so
the scheduled config entry reload triggered by async_update_reload_and_abort
is flushed before the assertions run.
@ronaldvdmeer ronaldvdmeer marked this pull request as ready for review April 20, 2026 21:02
Copilot AI review requested due to automatic review settings April 20, 2026 21:02
@home-assistant home-assistant bot requested a review from erwindouna April 20, 2026 21:02
Comment thread tests/components/duco/test_config_flow.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 adds a reconfiguration flow to the Duco integration, allowing users to change the configured host (IP/hostname) for an existing entry while ensuring the target device matches the existing entry’s unique ID (MAC).

Changes:

  • Add async_step_reconfigure to the Duco config flow, validating the new host and aborting on unique-id (MAC) mismatch.
  • Add UI strings for the reconfigure step and new abort reasons (reconfigure_successful, unique_id_mismatch).
  • Add tests for successful reconfigure, unique-id mismatch, and error paths; mark reconfiguration as done in the integration quality scale.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
homeassistant/components/duco/config_flow.py Implements the new reconfigure step, including host validation and unique-id mismatch abort handling.
homeassistant/components/duco/strings.json Adds translations for the reconfigure step and abort reasons used by the new flow.
homeassistant/components/duco/quality_scale.yaml Updates the integration quality scale to indicate reconfiguration support is complete.
tests/components/duco/test_config_flow.py Adds tests for reconfigure success, mismatch, and error paths.

Comment thread tests/components/duco/test_config_flow.py
Comment thread tests/components/duco/test_config_flow.py
Without a follow-up assertion that a reload actually occurred,
the call adds no value. The flow result assertions are sufficient.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants