Beispiel #1
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)
Beispiel #2
0
def to_code(config):
    rhs = App.make_template_cover(config[CONF_NAME])
    make = variable(MakeTemplateCover, config[CONF_MAKE_ID], rhs)

    if CONF_LAMBDA in config:
        template_ = process_lambda(config[CONF_LAMBDA], [])
        add(make.Ptemplate.set_state_lambda(template_))
    if CONF_OPEN_ACTION in config:
        actions = automation.build_actions(config[CONF_OPEN_ACTION], NoArg)
        add(make.Ptemplate_.add_open_actions(actions))
    if CONF_CLOSE_ACTION in config:
        actions = automation.build_actions(config[CONF_CLOSE_ACTION], NoArg)
        add(make.Ptemplate_.add_close_actions(actions))
    if CONF_STOP_ACTION in config:
        actions = automation.build_actions(config[CONF_STOP_ACTION], NoArg)
        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)
Beispiel #3
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]))