Fix interval trigger (#313)

This commit is contained in:
Otto Winter 2019-01-09 15:18:54 +01:00 committed by GitHub
parent cf73d777db
commit 5a1e806d14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 3 deletions

View File

@ -113,7 +113,11 @@ LambdaCondition = esphomelib_ns.class_('LambdaCondition', Condition)
def validate_automation(extra_schema=None, extra_validators=None, single=False): def validate_automation(extra_schema=None, extra_validators=None, single=False):
schema = AUTOMATION_SCHEMA.extend(extra_schema or {}) if extra_schema is None:
extra_schema = {}
if isinstance(extra_schema, vol.Schema):
extra_schema = extra_schema.schema
schema = AUTOMATION_SCHEMA.extend(extra_schema)
def validator_(value): def validator_(value):
if isinstance(value, list): if isinstance(value, list):

View File

@ -10,14 +10,14 @@ from esphomeyaml.cpp_types import App, NoArg, PollingComponent, Trigger, esphome
IntervalTrigger = esphomelib_ns.class_('IntervalTrigger', Trigger.template(NoArg), PollingComponent) IntervalTrigger = esphomelib_ns.class_('IntervalTrigger', Trigger.template(NoArg), PollingComponent)
CONFIG_SCHEMA = automation.validate_automation(vol.Schema({ CONFIG_SCHEMA = automation.validate_automation(vol.Schema({
vol.Required(CONF_ID): cv.declare_variable_id(IntervalTrigger), cv.GenerateID(): cv.declare_variable_id(IntervalTrigger),
vol.Required(CONF_INTERVAL): cv.positive_time_period_milliseconds, vol.Required(CONF_INTERVAL): cv.positive_time_period_milliseconds,
}).extend(cv.COMPONENT_SCHEMA.schema)) }).extend(cv.COMPONENT_SCHEMA.schema))
def to_code(config): def to_code(config):
for conf in config: for conf in config:
rhs = App.register_component(IntervalTrigger.new(config[CONF_INTERVAL])) rhs = App.register_component(IntervalTrigger.new(conf[CONF_INTERVAL]))
trigger = Pvariable(conf[CONF_ID], rhs) trigger = Pvariable(conf[CONF_ID], rhs)
setup_component(trigger, conf) setup_component(trigger, conf)

View File

@ -233,3 +233,8 @@ stepper:
# Optional: # Optional:
acceleration: inf acceleration: inf
deceleration: inf deceleration: inf
interval:
interval: 5s
then:
- logger.log: "Interval Run"