mirror of
https://github.com/home-assistant/core.git
synced 2025-07-17 18:27:09 +00:00
Fix flux_led discovery missing responses (#60464)
This commit is contained in:
parent
9b493be2b2
commit
a3e34c74db
@ -1,6 +1,7 @@
|
|||||||
"""The Flux LED/MagicLight integration."""
|
"""The Flux LED/MagicLight integration."""
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
import asyncio
|
||||||
from datetime import timedelta
|
from datetime import timedelta
|
||||||
import logging
|
import logging
|
||||||
from typing import Any, Final, cast
|
from typing import Any, Final, cast
|
||||||
@ -26,6 +27,7 @@ from .const import (
|
|||||||
DISCOVER_SCAN_TIMEOUT,
|
DISCOVER_SCAN_TIMEOUT,
|
||||||
DOMAIN,
|
DOMAIN,
|
||||||
FLUX_LED_DISCOVERY,
|
FLUX_LED_DISCOVERY,
|
||||||
|
FLUX_LED_DISCOVERY_LOCK,
|
||||||
FLUX_LED_EXCEPTIONS,
|
FLUX_LED_EXCEPTIONS,
|
||||||
SIGNAL_STATE_UPDATED,
|
SIGNAL_STATE_UPDATED,
|
||||||
STARTUP_SCAN_TIMEOUT,
|
STARTUP_SCAN_TIMEOUT,
|
||||||
@ -76,6 +78,10 @@ async def async_discover_devices(
|
|||||||
hass: HomeAssistant, timeout: int, address: str | None = None
|
hass: HomeAssistant, timeout: int, address: str | None = None
|
||||||
) -> list[dict[str, str]]:
|
) -> list[dict[str, str]]:
|
||||||
"""Discover flux led devices."""
|
"""Discover flux led devices."""
|
||||||
|
domain_data = hass.data.setdefault(DOMAIN, {})
|
||||||
|
if FLUX_LED_DISCOVERY_LOCK not in domain_data:
|
||||||
|
domain_data[FLUX_LED_DISCOVERY_LOCK] = asyncio.Lock()
|
||||||
|
async with domain_data[FLUX_LED_DISCOVERY_LOCK]:
|
||||||
scanner = AIOBulbScanner()
|
scanner = AIOBulbScanner()
|
||||||
try:
|
try:
|
||||||
discovered: list[dict[str, str]] = await scanner.async_scan(
|
discovered: list[dict[str, str]] = await scanner.async_scan(
|
||||||
@ -118,7 +124,7 @@ def async_trigger_discovery(
|
|||||||
|
|
||||||
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
async def async_setup(hass: HomeAssistant, config: ConfigType) -> bool:
|
||||||
"""Set up the flux_led component."""
|
"""Set up the flux_led component."""
|
||||||
domain_data = hass.data[DOMAIN] = {}
|
domain_data = hass.data.setdefault(DOMAIN, {})
|
||||||
domain_data[FLUX_LED_DISCOVERY] = await async_discover_devices(
|
domain_data[FLUX_LED_DISCOVERY] = await async_discover_devices(
|
||||||
hass, STARTUP_SCAN_TIMEOUT
|
hass, STARTUP_SCAN_TIMEOUT
|
||||||
)
|
)
|
||||||
|
@ -39,6 +39,7 @@ DEFAULT_SCAN_INTERVAL: Final = 5
|
|||||||
DEFAULT_EFFECT_SPEED: Final = 50
|
DEFAULT_EFFECT_SPEED: Final = 50
|
||||||
|
|
||||||
FLUX_LED_DISCOVERY: Final = "flux_led_discovery"
|
FLUX_LED_DISCOVERY: Final = "flux_led_discovery"
|
||||||
|
FLUX_LED_DISCOVERY_LOCK: Final = "flux_led_discovery_lock"
|
||||||
|
|
||||||
FLUX_LED_EXCEPTIONS: Final = (
|
FLUX_LED_EXCEPTIONS: Final = (
|
||||||
asyncio.TimeoutError,
|
asyncio.TimeoutError,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user