Fix: Config flow options ignored and Options flow 500 error#448
Open
maileys wants to merge 3 commits intosockless-coding:masterfrom
Open
Fix: Config flow options ignored and Options flow 500 error#448maileys wants to merge 3 commits intosockless-coding:masterfrom
maileys wants to merge 3 commits intosockless-coding:masterfrom
Conversation
Migrate initial setup options from entry.data to entry.options for consistent access. Fixes current issues with energy entities not being created on initial setup
thi should resolve the 500 error when accessing the configuration button in hass
There was a problem hiding this comment.
Pull request overview
This PR aims to ensure user-selected configuration/options (energy sensors, nanoe, preset naming, fetch intervals) are persisted correctly and applied consistently by the integration, and to fix a crash when opening the Options flow.
Changes:
- Pass full
user_inputthrough the config flow device creation path so selected options are saved into the config entry data. - Add a one-time migration in
async_setup_entry()to populateentry.optionsfromentry.datawhenentry.optionsis empty. - Adjust the Options flow handler initialization to avoid setting a now-read-only
config_entryproperty.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| custom_components/panasonic_cc/config_flow.py | Updates config flow to persist full user selections and modifies how the options flow handler is instantiated. |
| custom_components/panasonic_cc/init.py | Adds migration logic from entry.data → entry.options during setup to align with consumers reading entry.options. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Author
This was referenced May 5, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Fixes #403
Fixes #420
Three related bugs preventing user-selected config options (energy sensors, nanoe, preset names, fetch intervals) from being applied.
Bug 1: User input discarded in config flow (config_flow.py)
async_step_user() collects the full user_input dict (including energy sensor, nanoe, preset names, fetch intervals), but passes only username and password to _create_device() → _create_entry(), which hardcodes all other values to their defaults. The user's selections from the setup form are never saved.
Fix: Pass the full user_input dict through _create_device() → _create_entry() so all user-selected values are persisted to entry.data.
Bug 2: entry.data not migrated to entry.options (init.py)
The integration's consumers (switch.py, climate.py, coordinator.py, init.py) read settings from entry.options, but the initial config flow saves values to entry.data. entry.options is only populated after the Options flow is used. On a fresh install entry.options is empty, so all settings fall back to defaults.
Fix: Added a migration block in async_setup_entry() that populates entry.options from entry.data when entry.options is empty. This runs once on first startup after install, ensuring all consumers read the correct values without needing changes to each individual consumer.
Bug 3: Options flow crashes with 500 error (config_flow.py)
PanasonicOptionsFlowHandler.init() sets self.config_entry = config_entry, but newer Home Assistant versions made config_entry a read-only property on OptionsFlow. This raises AttributeError: property 'config_entry' of 'PanasonicOptionsFlowHandler' object has no setter, causing a 500 Internal Server Error when clicking Configure.
Fix: Removed the init method from PanasonicOptionsFlowHandler and removed the config_entry argument from the constructor call in async_get_options_flow(). The base OptionsFlow class already provides self.config_entry automatically.
Testing
Fresh install with energy sensor checkbox ticked → energy sensors created ✓
Fresh install with energy sensor checkbox unticked → no energy sensors ✓
Configure button (Options flow) no longer throws 500 error ✓
Options values correctly migrated from entry.data to entry.options on startup ✓
Existing installs with options already configured → behaviour unchanged ✓
Files changed
custom_components/panasonic_cc/init.py
custom_components/panasonic_cc/config_flow.py