FastLED power supply

This commit is contained in:
Otto Winter 2018-05-18 09:44:03 +02:00
parent 1a9ff55a61
commit 48e42cf478
No known key found for this signature in database
GPG key ID: DB66C0BE6013F97E
2 changed files with 17 additions and 6 deletions

View file

@ -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)

View file

@ -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)