Skip to content

fix(options): allow clearing ignored_addresses when omitted or empty in UI (#612) - #666

Merged
GreenGrassBlueOcean merged 2 commits into
OpenWebNet-HA:v2-phase1-architecturefrom
GreenGrassBlueOcean:fix/options-flow-clear-ignored-addresses
Oct 9, 2026
Merged

GreenGrassBlueOcean merged 2 commits into
OpenWebNet-HA:v2-phase1-architecturefrom
GreenGrassBlueOcean:fix/options-flow-clear-ignored-addresses

Conversation

@GreenGrassBlueOcean

Copy link
Copy Markdown
Contributor

Description

Fixes an issue reported in #612 (specifically issuecomment-6076280940) where clearing the Ignored addresses (ignored_addresses) field in the MyHOME Options flow had no effect, causing previously ignored addresses to keep reappearing upon reopening the configure dialog.

Root Cause

  1. In Home Assistant's web frontend (ha-selector-text.ts), clearing a non-required text selector field causes _handleChange to set value = undefined.
  2. ha-form merges { [schema.name]: undefined }.
  3. When the form is submitted via WebSocket/REST, JSON.stringify drops all properties with undefined values.
  4. Consequently, the payload received by Home Assistant backend omits the ignored_addresses key completely.
  5. In MyhomeOptionsFlowHandler.async_step_user, the code checked:
    if CONF_IGNORED_ADDRESSES in user_input:
        ...
    Because CONF_IGNORED_ADDRESSES was absent from user_input, this block was skipped entirely, preserving whatever entries were already loaded in self.options (from self.config_entry.options).
  6. The handler then saved self.options, persisting the old addresses back into entry.options.

Changes

  • config_flow.py:
    • Read user_input.get(CONF_IGNORED_ADDRESSES, "") unconditionally instead of checking if CONF_IGNORED_ADDRESSES in user_input. Because validate_ignored_addresses("") returns ([], True), clearing the field in the UI now properly empties self.options[CONF_IGNORED_ADDRESSES] = [].
    • Wrapped selector.TextSelector in vol.Maybe(...) so None and omitted values pass voluptuous schema validation cleanly.
  • tests/test_config_flow.py:
    • Added test cases verifying clearing ignored_addresses via empty string "", key omission (matching HA frontend behavior), None, and single comma , (UI workaround).
    • Verified that reopening the options flow after clearing pre-populates suggested_value == "".

Related to #612

…in UI (OpenWebNet-HA#612)

- Read CONF_IGNORED_ADDRESSES with fallback to empty string so clearing or omitting the field updates self.options to []
- Wrap multiline TextSelector with vol.Maybe so None and omitted inputs pass schema validation cleanly
- Add comprehensive options flow tests covering empty string, omitted key (HA frontend behavior), None, and single comma inputs
@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@GreenGrassBlueOcean
GreenGrassBlueOcean merged commit 0311277 into OpenWebNet-HA:v2-phase1-architecture Oct 9, 2026
16 checks passed
@GreenGrassBlueOcean
GreenGrassBlueOcean deleted the fix/options-flow-clear-ignored-addresses branch October 21, 2026 19:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants