From 5a1e806d149aab097716da0c52e154d88d99542b Mon Sep 17 00:00:00 2001 From: Otto Winter Date: Wed, 9 Jan 2019 15:18:54 +0100 Subject: [PATCH] Fix interval trigger (#313) --- esphomeyaml/automation.py | 6 +++++- esphomeyaml/components/interval.py | 4 ++-- tests/test2.yaml | 5 +++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/esphomeyaml/automation.py b/esphomeyaml/automation.py index eda83c6ec1..fff90e3824 100644 --- a/esphomeyaml/automation.py +++ b/esphomeyaml/automation.py @@ -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): diff --git a/esphomeyaml/components/interval.py b/esphomeyaml/components/interval.py index e41656ebb0..8429f6aed9 100644 --- a/esphomeyaml/components/interval.py +++ b/esphomeyaml/components/interval.py @@ -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) diff --git a/tests/test2.yaml b/tests/test2.yaml index 954bca77b6..24a8d0c8f7 100644 --- a/tests/test2.yaml +++ b/tests/test2.yaml @@ -233,3 +233,8 @@ stepper: # Optional: acceleration: inf deceleration: inf + +interval: + interval: 5s + then: + - logger.log: "Interval Run"