-
-
Notifications
You must be signed in to change notification settings - Fork 36.2k
Fix config flow reconfigure for Comelit #156193
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
Fix config flow reconfigure for Comelit #156193
Conversation
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.
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_reconfiguremethod to follow the standard pattern of checkinguser_input is not Noneinstead ofif 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, |
Copilot
AI
Nov 9, 2025
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.
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
| vol.Optional(CONF_PIN): cv.string, | |
| vol.Optional(CONF_PIN, default=reconfigure_entry.data.get(CONF_PIN)): cv.string, |
| data_to_validate = { | ||
| CONF_HOST: updated_host, | ||
| CONF_PORT: user_input[CONF_PORT], | ||
| CONF_PIN: user_input[CONF_PIN], |
Copilot
AI
Nov 9, 2025
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.
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.
| data_updates = { | ||
| CONF_HOST: updated_host, | ||
| CONF_PORT: user_input[CONF_PORT], | ||
| CONF_PIN: user_input[CONF_PIN], |
Copilot
AI
Nov 9, 2025
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.
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.
|
Thx ! |
Breaking change
Proposed change
Optimize reconfigure flow step by adding current settings to reconfigure form
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: