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):
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):
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)
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,
}).extend(cv.COMPONENT_SCHEMA.schema))
def to_code(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)
setup_component(trigger, conf)

View file

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