mirror of
https://github.com/esphome/esphome.git
synced 2024-11-22 11:47:30 +01:00
Fix interval trigger (#313)
This commit is contained in:
parent
cf73d777db
commit
5a1e806d14
@ -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):
|
||||
|
@ -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)
|
||||
|
||||
|
@ -233,3 +233,8 @@ stepper:
|
||||
# Optional:
|
||||
acceleration: inf
|
||||
deceleration: inf
|
||||
|
||||
interval:
|
||||
interval: 5s
|
||||
then:
|
||||
- logger.log: "Interval Run"
|
||||
|
Loading…
Reference in New Issue
Block a user