async_config_entry_first_refresh in update coordinator requires a config entry (#154114)

This commit is contained in:
G Johansson
2025-10-13 19:47:07 +02:00
committed by GitHub
parent 01dee6507b
commit 0bfdd70730
2 changed files with 7 additions and 9 deletions

View File

@@ -300,12 +300,11 @@ class DataUpdateCoordinator(BaseDataUpdateCoordinatorProtocol, Generic[_DataT]):
to ensure that multiple retries do not cause log spam. to ensure that multiple retries do not cause log spam.
""" """
if self.config_entry is None: if self.config_entry is None:
report_usage( raise ConfigEntryError(
"uses `async_config_entry_first_refresh`, which is only supported " "Detected code that uses `async_config_entry_first_refresh`,"
"for coordinators with a config entry", " which is only supported for coordinators with a config entry"
breaks_in_ha_version="2025.11",
) )
elif ( if (
self.config_entry.state self.config_entry.state
is not config_entries.ConfigEntryState.SETUP_IN_PROGRESS is not config_entries.ConfigEntryState.SETUP_IN_PROGRESS
): ):

View File

@@ -663,10 +663,9 @@ async def test_async_config_entry_first_refresh_no_entry(hass: HomeAssistant) ->
crd = get_crd(hass, DEFAULT_UPDATE_INTERVAL, None) crd = get_crd(hass, DEFAULT_UPDATE_INTERVAL, None)
crd.setup_method = AsyncMock() crd.setup_method = AsyncMock()
with pytest.raises( with pytest.raises(
RuntimeError, ConfigEntryError,
match="Detected code that uses `async_config_entry_first_refresh`," match="Detected code that uses `async_config_entry_first_refresh`,"
"which is only supported for coordinators with a config entry. " " which is only supported for coordinators with a config entry",
"Please report this issue",
): ):
await crd.async_config_entry_first_refresh() await crd.async_config_entry_first_refresh()