Skip to content

Refactor config options to use config_entry.options with fallback to config_entry.data #3365

@coderabbitai

Description

@coderabbitai

Context

Identified during review of PR #3344: #3344 (comment)

The options flow handler currently stores user-modified settings in config_entry.data instead of config_entry.options. In Home Assistant, .options is the standard location for user-modifiable settings from the options UI, while .data holds initial setup values.

Required Changes

1. Update OptionsFlowHandler in config_flow.py

  • Line 1017: Change to update with options=user_input instead of options=self.config_entry.options

2. Update option reading pattern across the codebase

Apply fallback pattern: config_entry.options.get(KEY, config_entry.data.get(KEY, DEFAULT))

Files to update:

  • runtime_data.py (lines 120-140): Update the options dict creation in __post_init__
  • __init__.py (lines 451-465, 2173): Update option reading locations

3. Configuration keys to update

  • CONF_INCLUDE_DEVICES
  • CONF_EXCLUDE_DEVICES
  • CONF_QUEUE_DELAY
  • CONF_SCAN_INTERVAL
  • CONF_PUBLIC_URL
  • CONF_EXTENDED_ENTITY_DISCOVERY
  • CONF_DEBUG

Benefits

  • Follow Home Assistant best practices for configuration management
  • Ensure UI-updated options are properly respected
  • Future-proof against HA core changes to configuration handling

References

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions