Skip to content

Conversation

@chemelli74
Copy link
Contributor

Breaking change

Proposed change

Optimize reconfigure flow step by adding current settings to reconfigure form

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

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:
  • Link to developer documentation pull request:
  • Link to frontend pull request:

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 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:

Copy link
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 refactors the reconfiguration flow in the Comelit integration to improve consistency with Home Assistant patterns and fix several issues with the previous implementation.

Key changes:

  • Restructured the async_step_reconfigure method to follow the standard pattern of checking user_input is not None instead of if not user_input
  • Fixed the form schema to show current values as defaults when the reconfigure form is first displayed
  • Updated data validation and storage to properly handle all reconfigurable fields (host, port, and pin)

vol.Required(
CONF_PORT, default=reconfigure_entry.data[CONF_PORT]
): cv.port,
vol.Optional(CONF_PIN): cv.string,
Copy link

Copilot AI Nov 9, 2025

Choose a reason for hiding this comment

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

The PIN field should have a default value from the existing config entry to display the current value to the user. This is inconsistent with how HOST and PORT are handled on lines 208 and 211. Change to: vol.Optional(CONF_PIN, default=reconfigure_entry.data.get(CONF_PIN)): cv.string

Suggested change
vol.Optional(CONF_PIN): cv.string,
vol.Optional(CONF_PIN, default=reconfigure_entry.data.get(CONF_PIN)): cv.string,

Copilot uses AI. Check for mistakes.
data_to_validate = {
CONF_HOST: updated_host,
CONF_PORT: user_input[CONF_PORT],
CONF_PIN: user_input[CONF_PIN],
Copy link

Copilot AI Nov 9, 2025

Choose a reason for hiding this comment

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

Using user_input[CONF_PIN] will raise a KeyError if the PIN field is not provided in the form (it's optional on line 213). The PIN field might be empty when the user doesn't want to change it. Use user_input.get(CONF_PIN, reconfigure_entry.data[CONF_PIN]) to fall back to the existing PIN value.

Copilot uses AI. Check for mistakes.
data_updates = {
CONF_HOST: updated_host,
CONF_PORT: user_input[CONF_PORT],
CONF_PIN: user_input[CONF_PIN],
Copy link

Copilot AI Nov 9, 2025

Choose a reason for hiding this comment

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

Using user_input[CONF_PIN] will raise a KeyError if the PIN field is not provided in the form (it's optional on line 213). Use user_input.get(CONF_PIN, reconfigure_entry.data[CONF_PIN]) to fall back to the existing PIN value when the user doesn't want to change it.

Copilot uses AI. Check for mistakes.
@joostlek joostlek merged commit 1e4d645 into home-assistant:dev Nov 10, 2025
41 of 42 checks passed
@chemelli74
Copy link
Contributor Author

Thx !

@chemelli74 chemelli74 deleted the chemelli74-comelit-reconfigure branch November 10, 2025 16:50
@github-actions github-actions bot locked and limited conversation to collaborators Nov 11, 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