Fix Interval Trigger

This commit is contained in:
Otto Winter 2019-01-02 16:49:26 +01:00
parent a110911371
commit dd801636af
No known key found for this signature in database
GPG key ID: DB66C0BE6013F97E
2 changed files with 4 additions and 2 deletions

View file

@ -2,7 +2,7 @@ import voluptuous as vol
from esphomeyaml import automation
import esphomeyaml.config_validation as cv
from esphomeyaml.const import CONF_ID
from esphomeyaml.const import CONF_ID, CONF_INTERVAL
from esphomeyaml.cpp_generator import Pvariable
from esphomeyaml.cpp_helpers import setup_component
from esphomeyaml.cpp_types import App, NoArg, PollingComponent, Trigger, esphomelib_ns
@ -11,12 +11,13 @@ IntervalTrigger = esphomelib_ns.class_('IntervalTrigger', Trigger.template(NoArg
CONFIG_SCHEMA = automation.validate_automation(vol.Schema({
vol.Required(CONF_ID): 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())
rhs = App.register_component(IntervalTrigger.new(config[CONF_INTERVAL]))
trigger = Pvariable(conf[CONF_ID], rhs)
setup_component(trigger, conf)

View file

@ -394,6 +394,7 @@ CONF_VARIABLES = 'variables'
CONF_SERVICE = 'service'
CONF_ENTITY_ID = 'entity_id'
CONF_RESTORE_MODE = 'restore_mode'
CONF_INTERVAL = 'interval'
ALLOWED_NAME_CHARS = u'abcdefghijklmnopqrstuvwxyz0123456789_'
ARDUINO_VERSION_ESP32_DEV = 'https://github.com/platformio/platform-espressif32.git#feature/stage'