Exemplo n.º 1
0
def build_automation_(trigger, args, config):
    arg_types = [arg[0] for arg in args]
    templ = TemplateArguments(*arg_types)
    rhs = App.make_automation(templ, trigger)
    type = Automation.template(templ)
    obj = Pvariable(config[CONF_AUTOMATION_ID], rhs, type=type)
    for actions in build_actions(config[CONF_THEN], templ, args):
        yield None
    add(obj.add_actions(actions))
    yield obj
Exemplo n.º 2
0
def build_automation_(trigger, arg_type, config):
    rhs = App.make_automation(TemplateArguments(arg_type), trigger)
    type = Automation.template(arg_type)
    obj = Pvariable(config[CONF_AUTOMATION_ID], rhs, type=type)
    if CONF_IF in config:
        conditions = None
        for conditions in build_conditions(config[CONF_IF], arg_type):
            yield None
        add(obj.add_conditions(conditions))
    actions = None
    for actions in build_actions(config[CONF_THEN], arg_type):
        yield None
    add(obj.add_actions(actions))
    yield obj