From fc2e36525f4f6156616bf69c15c479719e0f58e4 Mon Sep 17 00:00:00 2001 From: Dex Date: Sat, 19 Sep 2026 09:19:58 +0200 Subject: [PATCH] Stop forcing the Blink refresh on every poll (#182639) Co-authored-by: Dex --- homeassistant/components/blink/coordinator.py | 7 +++++- tests/components/blink/test_init.py | 23 +++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/homeassistant/components/blink/coordinator.py b/homeassistant/components/blink/coordinator.py index 0464e78f271b..3dc3572efe6f 100644 --- a/homeassistant/components/blink/coordinator.py +++ b/homeassistant/components/blink/coordinator.py @@ -62,6 +62,11 @@ class BlinkUpdateCoordinator(DataUpdateCoordinator[dict[str, Any]]): async def _async_update_data(self) -> dict[str, Any]: """Async update wrapper.""" try: - return await self.api.refresh(force=True) + # Do not force the refresh. BlinkPy turns a forced refresh into + # force_cache=True, which makes every sync module re-download media + # it already has, so cached clips are fetched again on every poll. + # The scan interval is far longer than BlinkPy's refresh rate, so a + # normal refresh still happens on schedule. + return await self.api.refresh() except UnauthorizedError as ex: raise ConfigEntryAuthFailed("Blink API authorization failed") from ex diff --git a/tests/components/blink/test_init.py b/tests/components/blink/test_init.py index 6bb6f21d1669..484aafe4f4b5 100644 --- a/tests/components/blink/test_init.py +++ b/tests/components/blink/test_init.py @@ -76,6 +76,29 @@ async def test_unload_entry( assert hass.services.has_service(DOMAIN, SERVICE_SAVE_VIDEO) +async def test_scheduled_refresh_is_not_forced( + hass: HomeAssistant, + mock_blink_api: MagicMock, + mock_blink_auth_api: MagicMock, + mock_config_entry: MockConfigEntry, +) -> None: + """Test a scheduled poll does not force a cache refresh. + + BlinkPy propagates a forced refresh as ``force_cache=True`` to the sync + modules, which re-downloads media that is already cached. See #182552. + """ + mock_config_entry.add_to_hass(hass) + assert await hass.config_entries.async_setup(mock_config_entry.entry_id) + await hass.async_block_till_done() + + mock_blink_api.refresh.reset_mock() + coordinator = mock_config_entry.runtime_data + await coordinator.async_refresh() + await hass.async_block_till_done() + + mock_blink_api.refresh.assert_awaited_once_with() + + async def test_migrate_V0( hass: HomeAssistant, mock_blink_api: MagicMock,