diff --git a/homeassistant/components/samsungtv/__init__.py b/homeassistant/components/samsungtv/__init__.py index c5814214bee..55d0fbdfbdb 100644 --- a/homeassistant/components/samsungtv/__init__.py +++ b/homeassistant/components/samsungtv/__init__.py @@ -165,10 +165,9 @@ class DebouncedEntryReloader: LOGGER.debug("Calling debouncer to get a reload after cooldown") await self._debounced_reload.async_call() - @callback - def async_shutdown(self) -> None: + async def async_shutdown(self) -> None: """Cancel any pending reload.""" - self._debounced_reload.async_shutdown() + await self._debounced_reload.async_shutdown() async def _async_reload_entry(self) -> None: """Reload entry.""" diff --git a/homeassistant/helpers/debounce.py b/homeassistant/helpers/debounce.py index 737d36ff33b..97381975f93 100644 --- a/homeassistant/helpers/debounce.py +++ b/homeassistant/helpers/debounce.py @@ -118,8 +118,7 @@ class Debouncer(Generic[_R_co]): # Schedule a new timer to prevent new runs during cooldown self._schedule_timer() - @callback - def async_shutdown(self) -> None: + async def async_shutdown(self) -> None: """Cancel any scheduled call, and prevent new runs.""" self._shutdown_requested = True self.async_cancel() diff --git a/tests/helpers/test_debounce.py b/tests/helpers/test_debounce.py index b54cfa0365d..ae69d40bdcb 100644 --- a/tests/helpers/test_debounce.py +++ b/tests/helpers/test_debounce.py @@ -202,7 +202,7 @@ async def test_shutdown(hass: HomeAssistant) -> None: # Ensure shutdown during a run doesn't create a cooldown timer hass.async_create_task(debouncer.async_call()) await asyncio.sleep(0.01) - debouncer.async_shutdown() + await debouncer.async_shutdown() future.set_result(True) await hass.async_block_till_done() assert len(calls) == 1