From 48e42cf478aa1339262a544d01ef768d635f104b Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Fri, 18 May 2018 09:44:03 +0200 Subject: [PATCH] FastLED power supply --- esphomeyaml/components/light/fastled_clockless.py | 12 +++++++++--- esphomeyaml/components/light/fastled_spi.py | 11 ++++++++--- 2 files changed, 17 insertions(+), 6 deletions(-) diff --git a/esphomeyaml/components/light/fastled_clockless.py b/esphomeyaml/components/light/fastled_clockless.py index 38711abc2c..85b1d95c97 100644 --- a/esphomeyaml/components/light/fastled_clockless.py +++ b/esphomeyaml/components/light/fastled_clockless.py @@ -4,9 +4,10 @@ import esphomeyaml.config_validation as cv from esphomeyaml import pins from esphomeyaml.components import light from esphomeyaml.const import CONF_CHIPSET, CONF_DEFAULT_TRANSITION_LENGTH, CONF_GAMMA_CORRECT, \ - CONF_ID, CONF_MAX_REFRESH_RATE, CONF_NAME, CONF_NUM_LEDS, CONF_PIN, CONF_RGB_ORDER -from esphomeyaml.helpers import App, RawExpression, TemplateArguments, add, setup_mqtt_component, \ - variable + CONF_ID, CONF_MAX_REFRESH_RATE, CONF_NAME, CONF_NUM_LEDS, CONF_PIN, CONF_POWER_SUPPLY, \ + CONF_RGB_ORDER +from esphomeyaml.helpers import App, RawExpression, TemplateArguments, add, get_variable, \ + setup_mqtt_component, variable TYPES = [ 'NEOPIXEL', @@ -63,6 +64,7 @@ PLATFORM_SCHEMA = vol.All(light.PLATFORM_SCHEMA.extend({ vol.Optional(CONF_GAMMA_CORRECT): cv.positive_float, vol.Optional(CONF_DEFAULT_TRANSITION_LENGTH): cv.positive_time_period_milliseconds, + vol.Optional(CONF_POWER_SUPPLY): cv.variable_id, }), validate) @@ -81,6 +83,10 @@ def to_code(config): if CONF_MAX_REFRESH_RATE in config: add(fast_led.set_max_refresh_rate(config[CONF_MAX_REFRESH_RATE])) + if CONF_POWER_SUPPLY in config: + power_supply = get_variable(config[CONF_POWER_SUPPLY]) + add(fast_led.set_power_supply(power_supply)) + setup_mqtt_component(make.Pmqtt, config) light.setup_light_component(make.Pstate, config) diff --git a/esphomeyaml/components/light/fastled_spi.py b/esphomeyaml/components/light/fastled_spi.py index e1a90447bc..62cb30dc08 100644 --- a/esphomeyaml/components/light/fastled_spi.py +++ b/esphomeyaml/components/light/fastled_spi.py @@ -5,9 +5,9 @@ from esphomeyaml import pins from esphomeyaml.components import light from esphomeyaml.const import CONF_CHIPSET, CONF_CLOCK_PIN, CONF_DATA_PIN, \ CONF_DEFAULT_TRANSITION_LENGTH, CONF_GAMMA_CORRECT, CONF_ID, CONF_MAX_REFRESH_RATE, CONF_NAME, \ - CONF_NUM_LEDS, CONF_RGB_ORDER -from esphomeyaml.helpers import App, TemplateArguments, add, setup_mqtt_component, variable, \ - RawExpression + CONF_NUM_LEDS, CONF_POWER_SUPPLY, CONF_RGB_ORDER +from esphomeyaml.helpers import App, RawExpression, TemplateArguments, add, get_variable, \ + setup_mqtt_component, variable CHIPSETS = [ 'LPD8806', @@ -42,6 +42,7 @@ PLATFORM_SCHEMA = light.PLATFORM_SCHEMA.extend({ vol.Optional(CONF_GAMMA_CORRECT): cv.positive_float, vol.Optional(CONF_DEFAULT_TRANSITION_LENGTH): cv.positive_time_period_milliseconds, + vol.Optional(CONF_POWER_SUPPLY): cv.variable_id, }) @@ -62,6 +63,10 @@ def to_code(config): if CONF_MAX_REFRESH_RATE in config: add(fast_led.set_max_refresh_rate(config[CONF_MAX_REFRESH_RATE])) + if CONF_POWER_SUPPLY in config: + power_supply = get_variable(config[CONF_POWER_SUPPLY]) + add(fast_led.set_power_supply(power_supply)) + setup_mqtt_component(make.Pmqtt, config) light.setup_light_component(make.Pstate, config)