mirror of
https://github.com/home-assistant/core.git
synced 2025-07-20 03:37:07 +00:00
Move imports to top for rpi_gpio_pwm (#29270)
This commit is contained in:
parent
453569a469
commit
3aff90c0ac
@ -1,22 +1,28 @@
|
|||||||
"""Support for LED lights that can be controlled using PWM."""
|
"""Support for LED lights that can be controlled using PWM."""
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
from pwmled import Color
|
||||||
|
from pwmled.driver.gpio import GpioDriver
|
||||||
|
from pwmled.driver.pca9685 import Pca9685Driver
|
||||||
|
from pwmled.led import SimpleLed
|
||||||
|
from pwmled.led.rgb import RgbLed
|
||||||
|
from pwmled.led.rgbw import RgbwLed
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.const import CONF_NAME, CONF_TYPE, STATE_ON, CONF_ADDRESS
|
|
||||||
from homeassistant.components.light import (
|
from homeassistant.components.light import (
|
||||||
Light,
|
|
||||||
ATTR_BRIGHTNESS,
|
ATTR_BRIGHTNESS,
|
||||||
ATTR_HS_COLOR,
|
ATTR_HS_COLOR,
|
||||||
ATTR_TRANSITION,
|
ATTR_TRANSITION,
|
||||||
|
PLATFORM_SCHEMA,
|
||||||
SUPPORT_BRIGHTNESS,
|
SUPPORT_BRIGHTNESS,
|
||||||
SUPPORT_COLOR,
|
SUPPORT_COLOR,
|
||||||
SUPPORT_TRANSITION,
|
SUPPORT_TRANSITION,
|
||||||
PLATFORM_SCHEMA,
|
Light,
|
||||||
)
|
)
|
||||||
|
from homeassistant.const import CONF_ADDRESS, CONF_NAME, CONF_TYPE, STATE_ON
|
||||||
import homeassistant.helpers.config_validation as cv
|
import homeassistant.helpers.config_validation as cv
|
||||||
import homeassistant.util.color as color_util
|
|
||||||
from homeassistant.helpers.restore_state import RestoreEntity
|
from homeassistant.helpers.restore_state import RestoreEntity
|
||||||
|
import homeassistant.util.color as color_util
|
||||||
|
|
||||||
_LOGGER = logging.getLogger(__name__)
|
_LOGGER = logging.getLogger(__name__)
|
||||||
|
|
||||||
@ -61,11 +67,6 @@ PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend(
|
|||||||
|
|
||||||
def setup_platform(hass, config, add_entities, discovery_info=None):
|
def setup_platform(hass, config, add_entities, discovery_info=None):
|
||||||
"""Set up the PWM LED lights."""
|
"""Set up the PWM LED lights."""
|
||||||
from pwmled.led import SimpleLed
|
|
||||||
from pwmled.led.rgb import RgbLed
|
|
||||||
from pwmled.led.rgbw import RgbwLed
|
|
||||||
from pwmled.driver.gpio import GpioDriver
|
|
||||||
from pwmled.driver.pca9685 import Pca9685Driver
|
|
||||||
|
|
||||||
leds = []
|
leds = []
|
||||||
for led_conf in config[CONF_LEDS]:
|
for led_conf in config[CONF_LEDS]:
|
||||||
@ -240,7 +241,6 @@ def _from_hass_brightness(brightness):
|
|||||||
|
|
||||||
def _from_hass_color(color):
|
def _from_hass_color(color):
|
||||||
"""Convert Home Assistant RGB list to Color tuple."""
|
"""Convert Home Assistant RGB list to Color tuple."""
|
||||||
from pwmled import Color
|
|
||||||
|
|
||||||
rgb = color_util.color_hs_to_RGB(*color)
|
rgb = color_util.color_hs_to_RGB(*color)
|
||||||
return Color(*tuple(rgb))
|
return Color(*tuple(rgb))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user