mirror of
https://github.com/esphome/esphome.git
synced 2024-11-29 10:14:13 +01:00
parent
846fcb8ccd
commit
c2f88776c7
2 changed files with 12 additions and 14 deletions
|
@ -1,18 +1,16 @@
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from esphomeyaml.automation import maybe_simple_id, ACTION_REGISTRY
|
from esphomeyaml.automation import ACTION_REGISTRY, maybe_simple_id
|
||||||
from esphomeyaml.components import mqtt
|
from esphomeyaml.components import mqtt
|
||||||
import esphomeyaml.config_validation as cv
|
import esphomeyaml.config_validation as cv
|
||||||
from esphomeyaml.const import CONF_ALPHA, CONF_BLUE, CONF_BRIGHTNESS, CONF_COLORS, \
|
from esphomeyaml.const import CONF_ALPHA, CONF_BLUE, CONF_BRIGHTNESS, CONF_COLORS, \
|
||||||
CONF_DEFAULT_TRANSITION_LENGTH, CONF_DURATION, CONF_EFFECTS, CONF_EFFECT_ID, \
|
CONF_COLOR_TEMPERATURE, CONF_DEFAULT_TRANSITION_LENGTH, CONF_DURATION, CONF_EFFECT, \
|
||||||
CONF_GAMMA_CORRECT, CONF_GREEN, CONF_ID, CONF_INTERNAL, CONF_LAMBDA, CONF_MQTT_ID, CONF_NAME, \
|
CONF_EFFECTS, CONF_EFFECT_ID, CONF_FLASH_LENGTH, CONF_GAMMA_CORRECT, CONF_GREEN, CONF_ID, \
|
||||||
CONF_NUM_LEDS, CONF_RANDOM, CONF_RED, CONF_SPEED, CONF_STATE, CONF_TRANSITION_LENGTH, \
|
CONF_INTERNAL, CONF_LAMBDA, CONF_MQTT_ID, CONF_NAME, CONF_NUM_LEDS, CONF_RANDOM, CONF_RED, \
|
||||||
CONF_UPDATE_INTERVAL, CONF_WHITE, CONF_WIDTH, CONF_FLASH_LENGTH, CONF_COLOR_TEMPERATURE, \
|
CONF_SPEED, CONF_STATE, CONF_TRANSITION_LENGTH, CONF_UPDATE_INTERVAL, CONF_WHITE, CONF_WIDTH
|
||||||
CONF_EFFECT
|
from esphomeyaml.helpers import Action, Application, ArrayInitializer, Component, Nameable, \
|
||||||
from esphomeyaml.helpers import Application, ArrayInitializer, Pvariable, RawExpression, \
|
Pvariable, StructInitializer, TemplateArguments, add, add_job, esphomelib_ns, float_, \
|
||||||
StructInitializer, add, add_job, esphomelib_ns, process_lambda, setup_mqtt_component, \
|
get_variable, process_lambda, setup_mqtt_component, std_string, templatable, uint32
|
||||||
get_variable, TemplateArguments, templatable, uint32, float_, std_string, Nameable, Component, \
|
|
||||||
Action
|
|
||||||
|
|
||||||
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend({
|
||||||
|
|
||||||
|
@ -32,7 +30,6 @@ TurnOnAction = light_ns.class_('TurnOnAction', Action)
|
||||||
|
|
||||||
LightColorValues = light_ns.class_('LightColorValues')
|
LightColorValues = light_ns.class_('LightColorValues')
|
||||||
|
|
||||||
|
|
||||||
MQTTJSONLightComponent = light_ns.class_('MQTTJSONLightComponent', mqtt.MQTTComponent)
|
MQTTJSONLightComponent = light_ns.class_('MQTTJSONLightComponent', mqtt.MQTTComponent)
|
||||||
|
|
||||||
# Effects
|
# Effects
|
||||||
|
@ -354,7 +351,6 @@ def setup_light(light_obj, mqtt_obj, config):
|
||||||
|
|
||||||
BUILD_FLAGS = '-DUSE_LIGHT'
|
BUILD_FLAGS = '-DUSE_LIGHT'
|
||||||
|
|
||||||
|
|
||||||
CONF_LIGHT_TOGGLE = 'light.toggle'
|
CONF_LIGHT_TOGGLE = 'light.toggle'
|
||||||
LIGHT_TOGGLE_ACTION_SCHEMA = maybe_simple_id({
|
LIGHT_TOGGLE_ACTION_SCHEMA = maybe_simple_id({
|
||||||
vol.Required(CONF_ID): cv.use_variable_id(LightState),
|
vol.Required(CONF_ID): cv.use_variable_id(LightState),
|
||||||
|
|
|
@ -9,7 +9,7 @@ SNTPComponent = time_.time_ns.class_('SNTPComponent', time_.RealTimeClockCompone
|
||||||
|
|
||||||
PLATFORM_SCHEMA = time_.TIME_PLATFORM_SCHEMA.extend({
|
PLATFORM_SCHEMA = time_.TIME_PLATFORM_SCHEMA.extend({
|
||||||
cv.GenerateID(): cv.declare_variable_id(SNTPComponent),
|
cv.GenerateID(): cv.declare_variable_id(SNTPComponent),
|
||||||
vol.Optional(CONF_SERVERS): vol.All(cv.ensure_list, [cv.string], vol.Length(max=3)),
|
vol.Optional(CONF_SERVERS): vol.All(cv.ensure_list, [cv.string], vol.Length(min=1, max=3)),
|
||||||
vol.Optional(CONF_LAMBDA): cv.lambda_,
|
vol.Optional(CONF_LAMBDA): cv.lambda_,
|
||||||
}).extend(cv.COMPONENT_SCHEMA.schema)
|
}).extend(cv.COMPONENT_SCHEMA.schema)
|
||||||
|
|
||||||
|
@ -18,7 +18,9 @@ def to_code(config):
|
||||||
rhs = App.make_sntp_component()
|
rhs = App.make_sntp_component()
|
||||||
sntp = Pvariable(config[CONF_ID], rhs)
|
sntp = Pvariable(config[CONF_ID], rhs)
|
||||||
if CONF_SERVERS in config:
|
if CONF_SERVERS in config:
|
||||||
add(sntp.set_servers(*config[CONF_SERVERS]))
|
servers = config[CONF_SERVERS]
|
||||||
|
servers += [''] * (3 - len(servers))
|
||||||
|
add(sntp.set_servers(*servers))
|
||||||
|
|
||||||
time_.setup_time(sntp, config)
|
time_.setup_time(sntp, config)
|
||||||
setup_component(sntp, config)
|
setup_component(sntp, config)
|
||||||
|
|
Loading…
Reference in a new issue