1 """The lifx integration discovery."""
3 from __future__
import annotations
6 from collections.abc
import Collection, Iterable
8 from aiolifx.aiolifx
import LifxDiscovery, Light, ScanManager
10 from homeassistant
import config_entries
16 from .const
import CONF_SERIAL, DOMAIN
22 """Discover lifx devices."""
23 all_lights: dict[str, Light] = {}
24 broadcast_addrs = await network.async_get_ipv4_broadcast_addresses(hass)
26 for address
in broadcast_addrs:
27 manager = ScanManager(
str(address))
28 lifx_discovery = LifxDiscovery(hass.loop, manager, broadcast_ip=
str(address))
29 discoveries.append(lifx_discovery)
30 lifx_discovery.start()
32 await asyncio.sleep(DEFAULT_TIMEOUT)
33 for discovery
in discoveries:
34 all_lights.update(discovery.lights)
37 return all_lights.values()
42 """Start discovery of devices."""
43 discovery_flow.async_create_flow(
46 context={
"source": config_entries.SOURCE_INTEGRATION_DISCOVERY},
47 data={CONF_HOST: host, CONF_SERIAL: serial},
54 discovered_devices: Iterable[Light],
56 """Trigger config flows for discovered devices."""
57 for device
in discovered_devices:
None async_trigger_discovery(HomeAssistant hass, Iterable[Light] discovered_devices)
None async_init_discovery_flow(HomeAssistant hass, str host, str serial)
Collection[Light] async_discover_devices(HomeAssistant hass)