Esempio n. 1
0
def to_code(config):
    rhs = App.make_template_switch(config[CONF_NAME])
    make = variable(config[CONF_MAKE_ID], rhs)

    if CONF_LAMBDA in config:
        template_ = None
        for template_ in process_lambda(config[CONF_LAMBDA], [],
                                        return_type=optional.template(bool_)):
            yield
        add(make.Ptemplate_.set_state_lambda(template_))
    if CONF_TURN_OFF_ACTION in config:
        actions = None
        for actions in automation.build_actions(config[CONF_TURN_OFF_ACTION],
                                                NoArg):
            yield
        add(make.Ptemplate_.add_turn_off_actions(actions))
    if CONF_TURN_ON_ACTION in config:
        actions = None
        for actions in automation.build_actions(config[CONF_TURN_ON_ACTION],
                                                NoArg):
            yield
        add(make.Ptemplate_.add_turn_on_actions(actions))
    if CONF_OPTIMISTIC in config:
        add(make.Ptemplate_.set_optimistic(config[CONF_OPTIMISTIC]))

    switch.setup_switch(make.Ptemplate_, make.Pmqtt, config)
Esempio n. 2
0
def to_code(config):
    rhs = App.make_template_cover(config[CONF_NAME])
    make = variable(config[CONF_MAKE_ID], rhs)

    if CONF_LAMBDA in config:
        template_ = None
        for template_ in process_lambda(config[CONF_LAMBDA], [],
                                        return_type=optional.template(
                                            cover.CoverState)):
            yield
        add(make.Ptemplate_.set_state_lambda(template_))
    if CONF_OPEN_ACTION in config:
        actions = None
        for actions in automation.build_actions(config[CONF_OPEN_ACTION],
                                                NoArg):
            yield
        add(make.Ptemplate_.add_open_actions(actions))
    if CONF_CLOSE_ACTION in config:
        actions = None
        for actions in automation.build_actions(config[CONF_CLOSE_ACTION],
                                                NoArg):
            yield
        add(make.Ptemplate_.add_close_actions(actions))
    if CONF_STOP_ACTION in config:
        actions = None
        for actions in automation.build_actions(config[CONF_STOP_ACTION],
                                                NoArg):
            yield
        add(make.Ptemplate_.add_stop_actions(actions))
    if CONF_OPTIMISTIC in config:
        add(make.Ptemplate_.set_optimistic(config[CONF_OPTIMISTIC]))

    cover.setup_cover(make.Ptemplate_, make.Pmqtt, config)
Esempio n. 3
0
def to_code(config):
    rhs = App.make_template_switch(config[CONF_NAME])
    make = variable(config[CONF_MAKE_ID], rhs)
    template = make.Ptemplate_

    switch.setup_switch(template, make.Pmqtt, config)

    if CONF_LAMBDA in config:
        for template_ in process_lambda(config[CONF_LAMBDA], [],
                                        return_type=optional.template(bool_)):
            yield
        add(template.set_state_lambda(template_))
    if CONF_TURN_OFF_ACTION in config:
        automation.build_automation(template.get_turn_off_trigger(), NoArg,
                                    config[CONF_TURN_OFF_ACTION])
    if CONF_TURN_ON_ACTION in config:
        automation.build_automation(template.get_turn_on_trigger(), NoArg,
                                    config[CONF_TURN_ON_ACTION])
    if CONF_OPTIMISTIC in config:
        add(template.set_optimistic(config[CONF_OPTIMISTIC]))

    if CONF_RESTORE_STATE in config:
        add(template.set_restore_state(config[CONF_RESTORE_STATE]))

    setup_component(template, config)
Esempio n. 4
0
def to_code(config):
    template_ = None
    for template_ in process_lambda(config[CONF_LAMBDA], [],
                                    return_type=optional.template(bool_)):
        yield
    rhs = App.make_template_binary_sensor(config[CONF_NAME], template_)
    make = variable(config[CONF_MAKE_ID], rhs)
    binary_sensor.setup_binary_sensor(make.Ptemplate_, make.Pmqtt, config)
Esempio n. 5
0
def to_code(config):
    template_ = None
    for template_ in process_lambda(config[CONF_LAMBDA], [],
                                    return_type=optional.template(float_)):
        yield
    rhs = App.make_template_sensor(config[CONF_NAME], template_,
                                   config.get(CONF_UPDATE_INTERVAL))
    make = variable(config[CONF_MAKE_ID], rhs)
    sensor.setup_sensor(make.Ptemplate_, make.Pmqtt, config)
Esempio n. 6
0
def to_code(config):
    rhs = App.make_template_text_sensor(config[CONF_NAME], config.get(CONF_UPDATE_INTERVAL))
    make = variable(config[CONF_MAKE_ID], rhs)
    template = make.Ptemplate_
    text_sensor.setup_text_sensor(template, make.Pmqtt, config)
    setup_component(template, config)

    for template_ in process_lambda(config[CONF_LAMBDA], [],
                                    return_type=optional.template(std_string)):
        yield
    add(template.set_template(template_))
Esempio n. 7
0
def to_code(config):
    rhs = App.make_template_cover(config[CONF_NAME])
    make = variable(config[CONF_MAKE_ID], rhs)

    cover.setup_cover(make.Ptemplate_, make.Pmqtt, config)
    setup_component(make.Ptemplate_, config)

    if CONF_LAMBDA in config:
        for template_ in process_lambda(config[CONF_LAMBDA], [],
                                        return_type=optional.template(
                                            cover.CoverState)):
            yield
        add(make.Ptemplate_.set_state_lambda(template_))
    if CONF_OPEN_ACTION in config:
        automation.build_automation(make.Ptemplate_.get_open_trigger(), NoArg,
                                    config[CONF_OPEN_ACTION])
    if CONF_CLOSE_ACTION in config:
        automation.build_automation(make.Ptemplate_.get_close_trigger(), NoArg,
                                    config[CONF_CLOSE_ACTION])
    if CONF_STOP_ACTION in config:
        automation.build_automation(make.Ptemplate_.get_stop_trigger(), NoArg,
                                    config[CONF_STOP_ACTION])
    if CONF_OPTIMISTIC in config:
        add(make.Ptemplate_.set_optimistic(config[CONF_OPTIMISTIC]))