mirror of
https://github.com/esphome/esphome.git
synced 2024-12-22 21:44:55 +01:00
parent
f087e313d4
commit
c3b2ab0085
2 changed files with 12 additions and 14 deletions
|
@ -1,18 +1,16 @@
|
|||
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
|
||||
import esphomeyaml.config_validation as cv
|
||||
from esphomeyaml.const import CONF_ALPHA, CONF_BLUE, CONF_BRIGHTNESS, CONF_COLORS, \
|
||||
CONF_DEFAULT_TRANSITION_LENGTH, CONF_DURATION, CONF_EFFECTS, CONF_EFFECT_ID, \
|
||||
CONF_GAMMA_CORRECT, CONF_GREEN, CONF_ID, CONF_INTERNAL, CONF_LAMBDA, CONF_MQTT_ID, CONF_NAME, \
|
||||
CONF_NUM_LEDS, CONF_RANDOM, CONF_RED, CONF_SPEED, CONF_STATE, CONF_TRANSITION_LENGTH, \
|
||||
CONF_UPDATE_INTERVAL, CONF_WHITE, CONF_WIDTH, CONF_FLASH_LENGTH, CONF_COLOR_TEMPERATURE, \
|
||||
CONF_EFFECT
|
||||
from esphomeyaml.helpers import Application, ArrayInitializer, Pvariable, RawExpression, \
|
||||
StructInitializer, add, add_job, esphomelib_ns, process_lambda, setup_mqtt_component, \
|
||||
get_variable, TemplateArguments, templatable, uint32, float_, std_string, Nameable, Component, \
|
||||
Action
|
||||
CONF_COLOR_TEMPERATURE, CONF_DEFAULT_TRANSITION_LENGTH, CONF_DURATION, CONF_EFFECT, \
|
||||
CONF_EFFECTS, CONF_EFFECT_ID, CONF_FLASH_LENGTH, CONF_GAMMA_CORRECT, CONF_GREEN, CONF_ID, \
|
||||
CONF_INTERNAL, CONF_LAMBDA, CONF_MQTT_ID, CONF_NAME, CONF_NUM_LEDS, CONF_RANDOM, CONF_RED, \
|
||||
CONF_SPEED, CONF_STATE, CONF_TRANSITION_LENGTH, CONF_UPDATE_INTERVAL, CONF_WHITE, CONF_WIDTH
|
||||
from esphomeyaml.helpers import Action, Application, ArrayInitializer, Component, Nameable, \
|
||||
Pvariable, StructInitializer, TemplateArguments, add, add_job, esphomelib_ns, float_, \
|
||||
get_variable, process_lambda, setup_mqtt_component, std_string, templatable, uint32
|
||||
|
||||
PLATFORM_SCHEMA = cv.PLATFORM_SCHEMA.extend({
|
||||
|
||||
|
@ -33,7 +31,6 @@ TurnOnAction = light_ns.class_('TurnOnAction', Action)
|
|||
|
||||
LightColorValues = light_ns.class_('LightColorValues')
|
||||
|
||||
|
||||
MQTTJSONLightComponent = light_ns.class_('MQTTJSONLightComponent', mqtt.MQTTComponent)
|
||||
|
||||
# Effects
|
||||
|
@ -354,7 +351,6 @@ def setup_light(light_obj, mqtt_obj, config):
|
|||
|
||||
BUILD_FLAGS = '-DUSE_LIGHT'
|
||||
|
||||
|
||||
CONF_LIGHT_TOGGLE = 'light.toggle'
|
||||
LIGHT_TOGGLE_ACTION_SCHEMA = maybe_simple_id({
|
||||
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({
|
||||
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_,
|
||||
}).extend(cv.COMPONENT_SCHEMA.schema)
|
||||
|
||||
|
@ -18,7 +18,9 @@ def to_code(config):
|
|||
rhs = App.make_sntp_component()
|
||||
sntp = Pvariable(config[CONF_ID], rhs)
|
||||
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)
|
||||
setup_component(sntp, config)
|
||||
|
|
Loading…
Reference in a new issue