From aba5dcb63e89462bc3ecd4d076bd65b91833b884 Mon Sep 17 00:00:00 2001 From: Joost Lekkerkerker Date: Mon, 18 Mar 2024 16:49:39 +0100 Subject: [PATCH] Patch Discovery timeout in govee light local (#113692) --- homeassistant/components/govee_light_local/config_flow.py | 4 +++- tests/components/govee_light_local/test_config_flow.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/govee_light_local/config_flow.py b/homeassistant/components/govee_light_local/config_flow.py index 8058668f0ca..bcf9886f6b4 100644 --- a/homeassistant/components/govee_light_local/config_flow.py +++ b/homeassistant/components/govee_light_local/config_flow.py @@ -20,6 +20,8 @@ from .const import ( _LOGGER = logging.getLogger(__name__) +DISCOVERY_TIMEOUT = 5 + async def _async_has_devices(hass: HomeAssistant) -> bool: """Return if there are devices that can be discovered.""" @@ -41,7 +43,7 @@ async def _async_has_devices(hass: HomeAssistant) -> bool: await controller.start() try: - async with asyncio.timeout(delay=5): + async with asyncio.timeout(delay=DISCOVERY_TIMEOUT): while not controller.devices: await asyncio.sleep(delay=1) except TimeoutError: diff --git a/tests/components/govee_light_local/test_config_flow.py b/tests/components/govee_light_local/test_config_flow.py index 2b527c867f9..b76d13a82fc 100644 --- a/tests/components/govee_light_local/test_config_flow.py +++ b/tests/components/govee_light_local/test_config_flow.py @@ -1,5 +1,4 @@ """Test Govee light local config flow.""" - from unittest.mock import AsyncMock, patch from govee_local_api import GoveeDevice @@ -21,6 +20,9 @@ async def test_creating_entry_has_no_devices( with patch( "homeassistant.components.govee_light_local.config_flow.GoveeController", return_value=mock_govee_api, + ), patch( + "homeassistant.components.govee_light_local.config_flow.DISCOVERY_TIMEOUT", + 0, ): result = await hass.config_entries.flow.async_init( DOMAIN, context={"source": config_entries.SOURCE_USER}