Simplify coroutine syntax (#503)

* Simplify coroutine syntax

* More

* Lint

* Fix

* More

* Lint
This commit is contained in:
Otto Winter
2019-04-09 14:30:12 +02:00
committed by GitHub
parent e90829eef2
commit be5330b6ae
103 changed files with 351 additions and 588 deletions
+4 -7
View File
@@ -27,9 +27,8 @@ def to_code(config):
setup_component(var, config)
if CONF_LAMBDA in config:
for template_ in process_lambda(config[CONF_LAMBDA], [],
return_type=optional.template(bool_)):
yield
template_ = yield process_lambda(config[CONF_LAMBDA], [],
return_type=optional.template(bool_))
add(var.set_template(template_))
@@ -45,12 +44,10 @@ BINARY_SENSOR_TEMPLATE_PUBLISH_ACTION_SCHEMA = cv.Schema({
@ACTION_REGISTRY.register(CONF_BINARY_SENSOR_TEMPLATE_PUBLISH,
BINARY_SENSOR_TEMPLATE_PUBLISH_ACTION_SCHEMA)
def binary_sensor_template_publish_to_code(config, action_id, template_arg, args):
for var in get_variable(config[CONF_ID]):
yield None
var = yield get_variable(config[CONF_ID])
rhs = var.make_binary_sensor_publish_action(template_arg)
type = BinarySensorPublishAction.template(template_arg)
action = Pvariable(action_id, rhs, type=type)
for template_ in templatable(config[CONF_STATE], args, bool_):
yield None
template_ = yield templatable(config[CONF_STATE], args, bool_)
add(action.set_state(template_))
yield action