Skip to content

Fix daikin setup_error on transient DaikinException during startup#173660

Open
BrettLynch123 wants to merge 2 commits into
home-assistant:devfrom
BrettLynch123:fix/daikin-exception-not-ready
Open

Fix daikin setup_error on transient DaikinException during startup#173660
BrettLynch123 wants to merge 2 commits into
home-assistant:devfrom
BrettLynch123:fix/daikin-exception-not-ready

Conversation

@BrettLynch123

Copy link
Copy Markdown
Contributor

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), DaikinFactory probes several device types in turn and ultimately calls DaikinAirBase.init(), which raises DaikinException("Empty values.") when the device responds but produces no usable data.

The existing try/except in async_setup_entry only caught TimeoutError and aiohttp.ClientConnectionError. DaikinException is a plain Exception subclass — not in either caught hierarchy — so it escaped entirely → HA's config-entry machinery caught it as an unexpected error and set the entry to setup_error with 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 ConfigEntryNotReady and let HA retry with backoff as intended.

Fix: add except DaikinException as err: raise ConfigEntryNotReady from err alongside the existing TimeoutError and ClientConnectionError handlers.

Type of change

  • Bugfix (non-breaking change which fixes an issue)

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • Tests have been added to verify the fix (test_daikin_exception_retries).
  • The documentation has been updated if necessary.
  • The changes have no obvious security issues.
  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies a diff between library versions and ideally a link to the changelog/release notes is added to the PR description.

To help with the load of incoming pull requests:

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
Copilot AI review requested due to automatic review settings June 13, 2026 05:37
@home-assistant

Copy link
Copy Markdown
Contributor

Hey there @fredrike, mind taking a look at this pull request as it has been labeled with an integration (daikin) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of daikin can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant mark-draft Mark the pull request as draft.
  • @home-assistant ready-for-review Remove the draft status from the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign daikin Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant update-branch Update the pull request branch with the base branch.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component, problem in config, problem in device, feature-request) on the pull request.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 DaikinException handler in async_setup_entry that raises ConfigEntryNotReady to 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Daikin Devices not connecting on reboot.

2 participants