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

Convert automation engine to use variadic templates (#452)

This commit is contained in:
Otto Winter
2019-02-26 19:28:11 +01:00
committed by GitHub
parent 1c7ca4bc6f
commit 3b00cfd6c4
27 changed files with 213 additions and 212 deletions

View File

@@ -44,7 +44,7 @@ def setup_text_sensor_core_(text_sensor_var, config):
for conf in config.get(CONF_ON_VALUE, []):
rhs = text_sensor_var.make_state_trigger()
trigger = Pvariable(conf[CONF_TRIGGER_ID], rhs)
automation.build_automation(trigger, std_string, conf)
automation.build_automations(trigger, [(std_string, 'x')], conf)
setup_mqtt_component(text_sensor_var.get_mqtt(), config)

View File

@@ -43,13 +43,13 @@ TEXT_SENSOR_TEMPLATE_PUBLISH_ACTION_SCHEMA = cv.Schema({
@ACTION_REGISTRY.register(CONF_TEXT_SENSOR_TEMPLATE_PUBLISH,
TEXT_SENSOR_TEMPLATE_PUBLISH_ACTION_SCHEMA)
def text_sensor_template_publish_to_code(config, action_id, arg_type, template_arg):
def text_sensor_template_publish_to_code(config, action_id, template_arg, args):
for var in get_variable(config[CONF_ID]):
yield None
rhs = var.make_text_sensor_publish_action(template_arg)
type = TextSensorPublishAction.template(arg_type)
type = TextSensorPublishAction.template(template_arg)
action = Pvariable(action_id, rhs, type=type)
for template_ in templatable(config[CONF_STATE], arg_type, std_string):
for template_ in templatable(config[CONF_STATE], args, std_string):
yield None
add(action.set_state(template_))
yield action