diff --git a/homeassistant/components/evohome/__init__.py b/homeassistant/components/evohome/__init__.py index 02d9b72cadc..98d72f828ae 100644 --- a/homeassistant/components/evohome/__init__.py +++ b/homeassistant/components/evohome/__init__.py @@ -32,6 +32,7 @@ from homeassistant.helpers.dispatcher import ( async_dispatcher_send, ) from homeassistant.helpers.entity import Entity +from homeassistant.helpers.event import async_call_later from homeassistant.helpers.service import verify_domain_control from homeassistant.helpers.typing import ConfigType import homeassistant.util.dt as dt_util @@ -434,7 +435,7 @@ class EvoBroker: return if update_state: # wait a moment for system to quiesce before updating state - self.hass.helpers.event.async_call_later(1, self._update_v2_api_state) + async_call_later(self.hass, 1, self._update_v2_api_state) return result diff --git a/homeassistant/components/konnected/panel.py b/homeassistant/components/konnected/panel.py index d02b4c31c33..2c7b57449b7 100644 --- a/homeassistant/components/konnected/panel.py +++ b/homeassistant/components/konnected/panel.py @@ -25,6 +25,7 @@ from homeassistant.const import ( from homeassistant.core import callback from homeassistant.helpers import aiohttp_client, device_registry as dr from homeassistant.helpers.dispatcher import async_dispatcher_send +from homeassistant.helpers.event import async_call_later from homeassistant.helpers.network import get_url from .const import ( @@ -136,8 +137,8 @@ class AlarmPanel: # retry in a bit, never more than ~3 min self.connect_attempts += 1 - self.cancel_connect_retry = self.hass.helpers.event.async_call_later( - 2 ** min(self.connect_attempts, 5) * 5, self.async_connect + self.cancel_connect_retry = async_call_later( + self.hass, 2 ** min(self.connect_attempts, 5) * 5, self.async_connect ) return diff --git a/homeassistant/components/sentry/__init__.py b/homeassistant/components/sentry/__init__.py index f51ea8a6b92..7ea26c04810 100644 --- a/homeassistant/components/sentry/__init__.py +++ b/homeassistant/components/sentry/__init__.py @@ -17,6 +17,7 @@ from homeassistant.const import ( ) from homeassistant.core import HomeAssistant from homeassistant.helpers import config_validation as cv, entity_platform +from homeassistant.helpers.event import async_call_later from homeassistant.loader import Integration, async_get_custom_components from .const import ( @@ -101,7 +102,7 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool: system_info = await hass.helpers.system_info.async_get_system_info() # Update system info every hour - hass.helpers.event.async_call_later(3600, update_system_info) + async_call_later(hass, 3600, update_system_info) hass.bus.async_listen_once(EVENT_HOMEASSISTANT_STARTED, update_system_info) diff --git a/homeassistant/components/squeezebox/media_player.py b/homeassistant/components/squeezebox/media_player.py index df6192459af..5fa79aad9a7 100644 --- a/homeassistant/components/squeezebox/media_player.py +++ b/homeassistant/components/squeezebox/media_player.py @@ -48,6 +48,7 @@ from homeassistant.helpers.dispatcher import ( async_dispatcher_send, ) from homeassistant.helpers.entity_platform import AddEntitiesCallback +from homeassistant.helpers.event import async_call_later from homeassistant.util.dt import utcnow from .browse_media import build_item_response, generate_playlist, library_payload @@ -178,7 +179,7 @@ async def async_setup_entry( hass.data[DOMAIN][config_entry.entry_id][ PLAYER_DISCOVERY_UNSUB - ] = hass.helpers.event.async_call_later(DISCOVERY_INTERVAL, _discovery) + ] = async_call_later(hass, DISCOVERY_INTERVAL, _discovery) _LOGGER.debug("Adding player discovery job for LMS server: %s", host) asyncio.create_task(_discovery()) diff --git a/homeassistant/config_entries.py b/homeassistant/config_entries.py index 9c1faf8f77a..d10315afa85 100644 --- a/homeassistant/config_entries.py +++ b/homeassistant/config_entries.py @@ -19,6 +19,7 @@ from .const import EVENT_HOMEASSISTANT_STARTED, EVENT_HOMEASSISTANT_STOP, Platfo from .core import CALLBACK_TYPE, CoreState, Event, HomeAssistant, callback from .exceptions import ConfigEntryAuthFailed, ConfigEntryNotReady, HomeAssistantError from .helpers import device_registry, entity_registry +from .helpers.event import async_call_later from .helpers.frame import report from .helpers.typing import UNDEFINED, ConfigType, DiscoveryInfoType, UndefinedType from .setup import async_process_deps_reqs, async_setup_component @@ -375,8 +376,8 @@ class ConfigEntry: await self.async_setup(hass, integration=integration, tries=tries) if hass.state == CoreState.running: - self._async_cancel_retry_setup = hass.helpers.event.async_call_later( - wait_time, setup_again + self._async_cancel_retry_setup = async_call_later( + hass, wait_time, setup_again ) else: self._async_cancel_retry_setup = hass.bus.async_listen_once( @@ -1561,8 +1562,8 @@ class EntityRegistryDisabledHandler: if self._remove_call_later: self._remove_call_later() - self._remove_call_later = self.hass.helpers.event.async_call_later( - RELOAD_AFTER_UPDATE_DELAY, self._handle_reload + self._remove_call_later = async_call_later( + self.hass, RELOAD_AFTER_UPDATE_DELAY, self._handle_reload ) async def _handle_reload(self, _now: Any) -> None: diff --git a/tests/test_config_entries.py b/tests/test_config_entries.py index abc5472200d..01a22dc1edb 100644 --- a/tests/test_config_entries.py +++ b/tests/test_config_entries.py @@ -886,7 +886,7 @@ async def test_setup_raise_not_ready(hass, caplog): mock_integration(hass, MockModule("test", async_setup_entry=mock_setup_entry)) mock_entity_platform(hass, "config_flow.test", None) - with patch("homeassistant.helpers.event.async_call_later") as mock_call: + with patch("homeassistant.config_entries.async_call_later") as mock_call: await entry.async_setup(hass) assert len(mock_call.mock_calls) == 1 @@ -921,7 +921,7 @@ async def test_setup_raise_not_ready_from_exception(hass, caplog): mock_integration(hass, MockModule("test", async_setup_entry=mock_setup_entry)) mock_entity_platform(hass, "config_flow.test", None) - with patch("homeassistant.helpers.event.async_call_later") as mock_call: + with patch("homeassistant.config_entries.async_call_later") as mock_call: await entry.async_setup(hass) assert len(mock_call.mock_calls) == 1 @@ -939,7 +939,7 @@ async def test_setup_retrying_during_unload(hass): mock_integration(hass, MockModule("test", async_setup_entry=mock_setup_entry)) mock_entity_platform(hass, "config_flow.test", None) - with patch("homeassistant.helpers.event.async_call_later") as mock_call: + with patch("homeassistant.config_entries.async_call_later") as mock_call: await entry.async_setup(hass) assert entry.state is config_entries.ConfigEntryState.SETUP_RETRY