mirror of
https://github.com/home-assistant/core.git
synced 2025-07-19 11:17:21 +00:00
Move imports to top for limitlessled (#29386)
This commit is contained in:
parent
cfe920079c
commit
7aab0d0aa0
@ -1,9 +1,16 @@
|
|||||||
"""Support for LimitlessLED bulbs."""
|
"""Support for LimitlessLED bulbs."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from limitlessled import Color
|
||||||
|
from limitlessled.bridge import Bridge
|
||||||
|
from limitlessled.group.dimmer import DimmerGroup
|
||||||
|
from limitlessled.group.rgbw import RgbwGroup
|
||||||
|
from limitlessled.group.rgbww import RgbwwGroup
|
||||||
|
from limitlessled.group.white import WhiteGroup
|
||||||
|
from limitlessled.pipeline import Pipeline
|
||||||
|
from limitlessled.presets import COLORLOOP
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import CONF_NAME, CONF_HOST, CONF_PORT, CONF_TYPE, STATE_ON
|
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
ATTR_COLOR_TEMP,
|
ATTR_COLOR_TEMP,
|
||||||
@ -14,18 +21,19 @@ from homeassistant.components.light import (
|
|||||||
EFFECT_COLORLOOP,
|
EFFECT_COLORLOOP,
|
||||||
EFFECT_WHITE,
|
EFFECT_WHITE,
|
||||||
FLASH_LONG,
|
FLASH_LONG,
|
||||||
|
PLATFORM_SCHEMA,
|
||||||
SUPPORT_BRIGHTNESS,
|
SUPPORT_BRIGHTNESS,
|
||||||
|
SUPPORT_COLOR,
|
||||||
SUPPORT_COLOR_TEMP,
|
SUPPORT_COLOR_TEMP,
|
||||||
SUPPORT_EFFECT,
|
SUPPORT_EFFECT,
|
||||||
SUPPORT_FLASH,
|
SUPPORT_FLASH,
|
||||||
SUPPORT_COLOR,
|
|
||||||
SUPPORT_TRANSITION,
|
SUPPORT_TRANSITION,
|
||||||
Light,
|
Light,
|
||||||
PLATFORM_SCHEMA,
|
|
||||||
)
|
)
|
||||||
|
from homeassistant.const import CONF_HOST, CONF_NAME, CONF_PORT, CONF_TYPE, STATE_ON
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
from homeassistant.util.color import color_temperature_mired_to_kelvin, color_hs_to_RGB
|
|
||||||
from homeassistant.helpers.restore_state import RestoreEntity
|
from homeassistant.helpers.restore_state import RestoreEntity
|
||||||
|
from homeassistant.util.color import color_hs_to_RGB, color_temperature_mired_to_kelvin
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -137,7 +145,6 @@ def rewrite_legacy(config):
|
|||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
"""Set up the LimitlessLED lights."""
|
"""Set up the LimitlessLED lights."""
|
||||||
from limitlessled.bridge import Bridge
|
|
||||||
|
|
||||||
# Two legacy configuration formats are supported to maintain backwards
|
# Two legacy configuration formats are supported to maintain backwards
|
||||||
# compatibility.
|
# compatibility.
|
||||||
@ -172,7 +179,6 @@ def state(new_state):
|
|||||||
# pylint: disable=protected-access
|
# pylint: disable=protected-access
|
||||||
def wrapper(self, **kwargs):
|
def wrapper(self, **kwargs):
|
||||||
"""Wrap a group state change."""
|
"""Wrap a group state change."""
|
||||||
from limitlessled.pipeline import Pipeline
|
|
||||||
|
|
||||||
pipeline = Pipeline()
|
pipeline = Pipeline()
|
||||||
transition_time = DEFAULT_TRANSITION
|
transition_time = DEFAULT_TRANSITION
|
||||||
@ -199,10 +205,6 @@ class LimitlessLEDGroup(Light, RestoreEntity):
|
|||||||
|
|
||||||
def __init__(self, group, config):
|
def __init__(self, group, config):
|
||||||
"""Initialize a group."""
|
"""Initialize a group."""
|
||||||
from limitlessled.group.rgbw import RgbwGroup
|
|
||||||
from limitlessled.group.white import WhiteGroup
|
|
||||||
from limitlessled.group.dimmer import DimmerGroup
|
|
||||||
from limitlessled.group.rgbww import RgbwwGroup
|
|
||||||
|
|
||||||
if isinstance(group, WhiteGroup):
|
if isinstance(group, WhiteGroup):
|
||||||
self._supported = SUPPORT_LIMITLESSLED_WHITE
|
self._supported = SUPPORT_LIMITLESSLED_WHITE
|
||||||
@ -366,8 +368,6 @@ class LimitlessLEDGroup(Light, RestoreEntity):
|
|||||||
# Add effects.
|
# Add effects.
|
||||||
if ATTR_EFFECT in kwargs and self._effect_list:
|
if ATTR_EFFECT in kwargs and self._effect_list:
|
||||||
if kwargs[ATTR_EFFECT] == EFFECT_COLORLOOP:
|
if kwargs[ATTR_EFFECT] == EFFECT_COLORLOOP:
|
||||||
from limitlessled.presets import COLORLOOP
|
|
||||||
|
|
||||||
self._effect = EFFECT_COLORLOOP
|
self._effect = EFFECT_COLORLOOP
|
||||||
pipeline.append(COLORLOOP)
|
pipeline.append(COLORLOOP)
|
||||||
if kwargs[ATTR_EFFECT] == EFFECT_WHITE:
|
if kwargs[ATTR_EFFECT] == EFFECT_WHITE:
|
||||||
@ -389,6 +389,5 @@ class LimitlessLEDGroup(Light, RestoreEntity):
|
|||||||
|
|
||||||
def limitlessled_color(self):
|
def limitlessled_color(self):
|
||||||
"""Convert Home Assistant HS list to RGB Color tuple."""
|
"""Convert Home Assistant HS list to RGB Color tuple."""
|
||||||
from limitlessled import Color
|
|
||||||
|
|
||||||
return Color(*color_hs_to_RGB(*tuple(self._color)))
|
return Color(*color_hs_to_RGB(*tuple(self._color)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user