mirror of
https://github.com/home-assistant/core.git
synced 2025-07-12 15:57:06 +00:00
Patch Discovery timeout in govee light local (#113692)
This commit is contained in:
parent
eaf86ee1ea
commit
aba5dcb63e
@ -20,6 +20,8 @@ from .const import (
|
|||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
DISCOVERY_TIMEOUT = 5
|
||||||
|
|
||||||
|
|
||||||
async def _async_has_devices(hass: HomeAssistant) -> bool:
|
async def _async_has_devices(hass: HomeAssistant) -> bool:
|
||||||
"""Return if there are devices that can be discovered."""
|
"""Return if there are devices that can be discovered."""
|
||||||
@ -41,7 +43,7 @@ async def _async_has_devices(hass: HomeAssistant) -> bool:
|
|||||||
await controller.start()
|
await controller.start()
|
||||||
|
|
||||||
try:
|
try:
|
||||||
async with asyncio.timeout(delay=5):
|
async with asyncio.timeout(delay=DISCOVERY_TIMEOUT):
|
||||||
while not controller.devices:
|
while not controller.devices:
|
||||||
await asyncio.sleep(delay=1)
|
await asyncio.sleep(delay=1)
|
||||||
except TimeoutError:
|
except TimeoutError:
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
"""Test Govee light local config flow."""
|
"""Test Govee light local config flow."""
|
||||||
|
|
||||||
from unittest.mock import AsyncMock, patch
|
from unittest.mock import AsyncMock, patch
|
||||||
|
|
||||||
from govee_local_api import GoveeDevice
|
from govee_local_api import GoveeDevice
|
||||||
@ -21,6 +20,9 @@ async def test_creating_entry_has_no_devices(
|
|||||||
with patch(
|
with patch(
|
||||||
"homeassistant.components.govee_light_local.config_flow.GoveeController",
|
"homeassistant.components.govee_light_local.config_flow.GoveeController",
|
||||||
return_value=mock_govee_api,
|
return_value=mock_govee_api,
|
||||||
|
), patch(
|
||||||
|
"homeassistant.components.govee_light_local.config_flow.DISCOVERY_TIMEOUT",
|
||||||
|
0,
|
||||||
):
|
):
|
||||||
result = await hass.config_entries.flow.async_init(
|
result = await hass.config_entries.flow.async_init(
|
||||||
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
DOMAIN, context={"source": config_entries.SOURCE_USER}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user