From 5841269ff7a93822379bca745d71c92e04ee3027 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 17 May 2026 16:08:33 +0000 Subject: [PATCH 1/3] Prevent Google Assistant entity sync from blocking startup Co-Authored-By: Claude Opus 4.6 (1M context) --- homeassistant/components/google_assistant/helpers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/homeassistant/components/google_assistant/helpers.py b/homeassistant/components/google_assistant/helpers.py index 72d9c7bb089ff0..d39ea97537a265 100644 --- a/homeassistant/components/google_assistant/helpers.py +++ b/homeassistant/components/google_assistant/helpers.py @@ -112,7 +112,7 @@ async def sync_google(_): """Sync entities to Google.""" await self.async_sync_entities_all() - self._on_deinitialize.append(start.async_at_start(self.hass, sync_google)) + self._on_deinitialize.append(start.async_at_started(self.hass, sync_google)) @callback def async_deinitialize(self) -> None: From 40c4ab942f10df99108226cbac13d169be8abc9e Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 17 May 2026 16:11:49 +0000 Subject: [PATCH 2/3] Add test verifying entity sync does not block startup Co-Authored-By: Claude Opus 4.6 (1M context) --- .../components/google_assistant/test_http.py | 27 +++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/tests/components/google_assistant/test_http.py b/tests/components/google_assistant/test_http.py index 6d0888dcf38a19..f4804ea3be94a3 100644 --- a/tests/components/google_assistant/test_http.py +++ b/tests/components/google_assistant/test_http.py @@ -28,8 +28,12 @@ _get_homegraph_token, async_get_users, ) -from homeassistant.const import CLOUD_NEVER_EXPOSED_ENTITIES -from homeassistant.core import HomeAssistant, State +from homeassistant.const import ( + CLOUD_NEVER_EXPOSED_ENTITIES, + EVENT_HOMEASSISTANT_START, + EVENT_HOMEASSISTANT_STARTED, +) +from homeassistant.core import CoreState, HomeAssistant, State from homeassistant.setup import async_setup_component from homeassistant.util import dt as dt_util @@ -78,6 +82,25 @@ } +async def test_sync_google_does_not_block_startup(hass: HomeAssistant) -> None: + """Test that Google entity sync runs after startup, not during.""" + hass.set_state(CoreState.not_running) + config = GoogleConfig(hass, DUMMY_CONFIG) + + with patch.object(config, "async_sync_entities_all") as mock_sync: + await config.async_initialize() + + # Fire EVENT_HOMEASSISTANT_START - sync should NOT run yet + hass.bus.async_fire(EVENT_HOMEASSISTANT_START) + await hass.async_block_till_done() + mock_sync.assert_not_called() + + # Fire EVENT_HOMEASSISTANT_STARTED - now sync should run + hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED) + await hass.async_block_till_done() + mock_sync.assert_called_once() + + async def test_get_jwt(hass: HomeAssistant) -> None: """Test signing of key.""" From 1f3d6c6296688a2c9175c6c25362d741ad99724e Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Sun, 17 May 2026 17:01:36 +0000 Subject: [PATCH 3/3] Update cloud google config test to expect sync on started, not start Co-Authored-By: Claude Opus 4.6 (1M context) --- tests/components/cloud/test_google_config.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/components/cloud/test_google_config.py b/tests/components/cloud/test_google_config.py index 91a7b2169c3588..3083c24a6137ea 100644 --- a/tests/components/cloud/test_google_config.py +++ b/tests/components/cloud/test_google_config.py @@ -372,6 +372,10 @@ async def test_sync_google_on_home_assistant_start( hass.bus.async_fire(EVENT_HOMEASSISTANT_START) await hass.async_block_till_done() + assert len(mock_sync.mock_calls) == 0 + + hass.bus.async_fire(EVENT_HOMEASSISTANT_STARTED) + await hass.async_block_till_done() assert len(mock_sync.mock_calls) == 1