From 6457d4610732638425ab24b22da0bec671d5aa3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ab=C3=ADlio=20Costa?= Date: Thu, 24 Apr 2025 19:25:15 +0100 Subject: [PATCH] Raise `ConfigEntryNotReady` when fetching Whirlpool appliances fails (#143601) --- homeassistant/components/whirlpool/__init__.py | 5 +++-- homeassistant/components/whirlpool/strings.json | 3 +++ tests/components/whirlpool/test_init.py | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/homeassistant/components/whirlpool/__init__.py b/homeassistant/components/whirlpool/__init__.py index fec26f03691..86d1495d6dc 100644 --- a/homeassistant/components/whirlpool/__init__.py +++ b/homeassistant/components/whirlpool/__init__.py @@ -47,8 +47,9 @@ async def async_setup_entry(hass: HomeAssistant, entry: WhirlpoolConfigEntry) -> appliances_manager = AppliancesManager(backend_selector, auth, session) if not await appliances_manager.fetch_appliances(): - _LOGGER.error("Cannot fetch appliances") - return False + raise ConfigEntryNotReady( + translation_domain=DOMAIN, translation_key="appliances_fetch_failed" + ) await appliances_manager.connect() entry.runtime_data = appliances_manager diff --git a/homeassistant/components/whirlpool/strings.json b/homeassistant/components/whirlpool/strings.json index 8f38330980e..2a22a2e8e4e 100644 --- a/homeassistant/components/whirlpool/strings.json +++ b/homeassistant/components/whirlpool/strings.json @@ -128,6 +128,9 @@ "exceptions": { "account_locked": { "message": "[%key:component::whirlpool::common::account_locked_error%]" + }, + "appliances_fetch_failed": { + "message": "Failed to fetch appliances" } } } diff --git a/tests/components/whirlpool/test_init.py b/tests/components/whirlpool/test_init.py index 06e82b74ba7..d33bd8be0e1 100644 --- a/tests/components/whirlpool/test_init.py +++ b/tests/components/whirlpool/test_init.py @@ -129,7 +129,7 @@ async def test_setup_fetch_appliances_failed( mock_appliances_manager_api.return_value.fetch_appliances.return_value = False entry = await init_integration(hass) assert len(hass.config_entries.async_entries(DOMAIN)) == 1 - assert entry.state is ConfigEntryState.SETUP_ERROR + assert entry.state is ConfigEntryState.SETUP_RETRY async def test_unload_entry(hass: HomeAssistant) -> None: