Skip to content

fix(config_flow): 🐛 stop DHCP discovery double-reloading config entries#670

Merged
rhammen merged 1 commit into
mainfrom
fix/dhcp-discovery-double-reload
Jul 4, 2026
Merged

fix(config_flow): 🐛 stop DHCP discovery double-reloading config entries#670
rhammen merged 1 commit into
mainfrom
fix/dhcp-discovery-double-reload

Conversation

@rhammen

@rhammen rhammen commented Jul 4, 2026

Copy link
Copy Markdown
Collaborator

🐞 Problem

WARNING (MainThread) [homeassistant.helpers.frame] Detected that custom integration 'luxtronik2' has an update listener and should use it for scheduling a reload. This will stop working in Home Assistant 2026.12.0, please create a bug report at https://github.com/BenPru/luxtronik/issues

🔍 Root cause

__init__.py registers a generic update listener (entry.add_update_listener(update_listener)) whose body unconditionally calls hass.config_entries.async_reload(...). Home Assistant fires update_listeners on any entry change, not just options-flow changes — including data changes.

async_step_dhcp in config_flow.py calls _abort_if_unique_id_configured(updates={...}) to silently keep a rediscovered device's host/port in sync. That data update:

  • immediately fires our own update_listener, which schedules a reload, and
  • separately, since reload_on_update defaults to True, core also schedules its own reload for the same entry, logging this deprecation warning in the process.

So a single DHCP rediscovery currently triggers two redundant reload schedules for the same entry. HA is deprecating this combination and it will stop working in 2026.12.0.

🔧 Fix

Pass reload_on_update=False to _abort_if_unique_id_configured in async_step_dhcp, since our own update listener already reloads the entry whenever its data changes. Core no longer needs to (and shouldn't) schedule a second reload.

🧪 Testing

  • pytest -k dhcp -q — 5 passed
  • ruff check — clean
  • basedpyright — 0 errors

✅ Test plan

  • Confirm DHCP rediscovery of an already-configured heat pump at a new IP still updates the entry's host/port
  • Confirm the deprecation warning no longer appears in the log after a DHCP rediscovery event

🤖 Generated with Claude Code

- DHCP rediscovery updates the entry's host/port via
  _abort_if_unique_id_configured(updates=...), which by default also has
  core schedule its own reload
- our update listener already reloads the entry on any data/options
  change, so the core-scheduled reload was redundant and triggered HA's
  "has an update listener and should use it for scheduling a reload"
  deprecation warning, set to break in 2026.12.0
- pass reload_on_update=False so core skips its own reload and leaves it
  to our listener

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Base automatically changed from fix/options-flow-update-interval-serialization to main July 4, 2026 11:43
@rhammen rhammen merged commit 4bb8795 into main Jul 4, 2026
7 checks passed
@rhammen rhammen deleted the fix/dhcp-discovery-double-reload branch July 4, 2026 11:44
@rhammen rhammen mentioned this pull request Jul 4, 2026
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.

1 participant