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