1
mirror of https://github.com/home-assistant/core synced 2024-08-28 03:36:46 +02:00
ha-core/homeassistant/components/hue/light.py
Marcel van der Veldt e1e6925097
Refactor of Hue integration with full V2 support (#58996)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2021-11-16 11:59:17 -08:00

29 lines
993 B
Python

"""Support for Hue lights."""
from __future__ import annotations
from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback
from .bridge import HueBridge
from .const import DOMAIN
from .v1.light import async_setup_entry as setup_entry_v1
from .v2.group import async_setup_entry as setup_groups_entry_v2
from .v2.light import async_setup_entry as setup_entry_v2
async def async_setup_entry(
hass: HomeAssistant,
config_entry: ConfigEntry,
async_add_entities: AddEntitiesCallback,
) -> None:
"""Set up light entities."""
bridge: HueBridge = hass.data[DOMAIN][config_entry.entry_id]
if bridge.api_version == 1:
await setup_entry_v1(hass, config_entry, async_add_entities)
return
# v2 setup logic here
await setup_entry_v2(hass, config_entry, async_add_entities)
await setup_groups_entry_v2(hass, config_entry, async_add_entities)