mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 05:07:41 +00:00
Replace ValueError with deprecation in data update coordinator (#128082)
* Replace ValueError with deprecation in data update coordinator * Rephrase
This commit is contained in:
parent
554629f37a
commit
63391717e7
@ -29,6 +29,7 @@ from homeassistant.util.dt import utcnow
|
|||||||
|
|
||||||
from . import entity, event
|
from . import entity, event
|
||||||
from .debounce import Debouncer
|
from .debounce import Debouncer
|
||||||
|
from .frame import report
|
||||||
from .typing import UNDEFINED, UndefinedType
|
from .typing import UNDEFINED, UndefinedType
|
||||||
|
|
||||||
REQUEST_REFRESH_DEFAULT_COOLDOWN = 10
|
REQUEST_REFRESH_DEFAULT_COOLDOWN = 10
|
||||||
@ -285,8 +286,12 @@ 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:
|
||||||
raise ValueError(
|
report(
|
||||||
"This method is only supported for coordinators with a config entry"
|
"uses `async_config_entry_first_refresh`, which is only supported "
|
||||||
|
"for coordinators with a config entry and will stop working in "
|
||||||
|
"Home Assistant 2025.11",
|
||||||
|
error_if_core=True,
|
||||||
|
error_if_integration=False,
|
||||||
)
|
)
|
||||||
if await self.__wrap_async_setup():
|
if await self.__wrap_async_setup():
|
||||||
await self._async_refresh(
|
await self._async_refresh(
|
||||||
|
@ -613,8 +613,10 @@ 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(
|
||||||
ValueError,
|
RuntimeError,
|
||||||
match="This method is only supported for coordinators with a config entry",
|
match="Detected code that uses `async_config_entry_first_refresh`, "
|
||||||
|
"which is only supported for coordinators with a config entry and will "
|
||||||
|
"stop working in Home Assistant 2025.11. Please report this issue.",
|
||||||
):
|
):
|
||||||
await crd.async_config_entry_first_refresh()
|
await crd.async_config_entry_first_refresh()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user