Fix daikin setup_error on transient DaikinException during startup#173660
Open
BrettLynch123 wants to merge 2 commits into
Open
Fix daikin setup_error on transient DaikinException during startup#173660BrettLynch123 wants to merge 2 commits into
BrettLynch123 wants to merge 2 commits into
Conversation
When HA restarts while a Daikin device's HTTP endpoint is not yet ready
(e.g. the AC unit has not finished booting, or returns an empty response),
DaikinFactory calls DaikinAirBase.init() which raises DaikinException("Empty
values."). The existing try/except in async_setup_entry only caught
TimeoutError and aiohttp.ClientConnectionError, so DaikinException escaped →
HA marked the entry setup_error with no automatic retry, requiring a manual
reload.
DaikinException at factory time is a transient, not a configuration error:
the pydaikin library raises it when the device responds but produces no
usable data. Catch it alongside the other transient errors and raise
ConfigEntryNotReady so HA retries with backoff as intended.
Fixes home-assistant#168471
Contributor
|
Hey there @fredrike, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR ensures that DaikinException raised during setup of the Daikin integration triggers a config entry retry (SETUP_RETRY) instead of a permanent setup error, treating it as a transient condition (e.g., device returning an empty response while not yet ready).
Changes:
- Added a new
except DaikinExceptionhandler inasync_setup_entrythat raisesConfigEntryNotReadyto trigger retry. - Added a corresponding test (
test_daikin_exception_retries) verifying the retry behavior.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
homeassistant/components/daikin/__init__.py |
Catches DaikinException during setup and raises ConfigEntryNotReady for retry. |
tests/components/daikin/test_init.py |
Adds a test asserting DaikinException results in SETUP_RETRY. |
Comment on lines
+60
to
+62
| except DaikinException as err: | ||
| _LOGGER.debug("DaikinException from %s: %s", host, err) | ||
| raise ConfigEntryNotReady from err |
pydaikin has no exception subclass hierarchy distinguishing transient from permanent errors. Add a comment explaining why catching the base class is the correct approach at factory-time: the device is a local LAN device with no auth surface at setup, and DaikinException during DaikinFactory almost exclusively indicates the unit is not yet ready (e.g. "Empty values." on early boot), not a permanent misconfiguration.
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.
Proposed change
When HA restarts while a Daikin device's HTTP endpoint is not yet ready (e.g. the AC unit has not finished booting, or returns an empty response body),
DaikinFactoryprobes several device types in turn and ultimately callsDaikinAirBase.init(), which raisesDaikinException("Empty values.")when the device responds but produces no usable data.The existing try/except in
async_setup_entryonly caughtTimeoutErrorandaiohttp.ClientConnectionError.DaikinExceptionis a plainExceptionsubclass — not in either caught hierarchy — so it escaped entirely → HA's config-entry machinery caught it as an unexpected error and set the entry tosetup_errorwith no automatic retry. A manual reload was required each time.This is a transient condition (the device is temporarily not ready, not permanently misconfigured), so it should raise
ConfigEntryNotReadyand let HA retry with backoff as intended.Fix: add
except DaikinException as err: raise ConfigEntryNotReady from erralongside the existingTimeoutErrorandClientConnectionErrorhandlers.Type of change
Additional information
Checklist
test_daikin_exception_retries).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: