1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-10 07:12:21 +01:00

New coroutine-based task execution

This commit is contained in:
Otto Winter
2018-06-02 22:22:20 +02:00
parent 2db45898e2
commit 6e85a741ae
76 changed files with 1145 additions and 678 deletions

View File

@@ -5,18 +5,20 @@ from esphomeyaml.components import switch
from esphomeyaml.const import CONF_MAKE_ID, CONF_NAME, CONF_OUTPUT
from esphomeyaml.helpers import App, Application, get_variable, variable
PLATFORM_SCHEMA = switch.PLATFORM_SCHEMA.extend({
cv.GenerateID('output_switch', CONF_MAKE_ID): cv.register_variable_id,
vol.Required(CONF_OUTPUT): cv.variable_id,
}).extend(switch.SWITCH_SCHEMA.schema)
MakeSimpleSwitch = Application.MakeSimpleSwitch
PLATFORM_SCHEMA = switch.PLATFORM_SCHEMA.extend({
cv.GenerateID(CONF_MAKE_ID): cv.declare_variable_id(MakeSimpleSwitch),
vol.Required(CONF_OUTPUT): cv.use_variable_id(None),
}).extend(switch.SWITCH_SCHEMA.schema)
def to_code(config):
output = get_variable(config[CONF_OUTPUT])
output = None
for output in get_variable(config[CONF_OUTPUT]):
yield
rhs = App.make_simple_switch(config[CONF_NAME], output)
gpio = variable(MakeSimpleSwitch, config[CONF_MAKE_ID], rhs)
gpio = variable(config[CONF_MAKE_ID], rhs)
switch.setup_switch(gpio.Pswitch_, gpio.Pmqtt, config)