Exemple #1
0
def to_code(config):
    var = cg.new_Pvariable(config[CONF_ID])
    cg.add(var.set_pin(config[CONF_PIN]))
    cg.add(var.set_invert_position(config[CONF_INVERT_POSITION]))
    yield cg.register_component(var, config)
    yield cover.register_cover(var, config)
    yield ble_client.register_ble_node(var, config)
def to_code(config):
    var = cg.new_Pvariable(config[CONF_ID])
    yield cg.register_component(var, config)
    yield cover.register_cover(var, config)

    yield automation.build_automation(
        var.get_stop_trigger(), [], config[CONF_STOP_ACTION]
    )

    bin = yield cg.get_variable(config[CONF_OPEN_ENDSTOP])
    cg.add(var.set_open_endstop(bin))
    cg.add(var.set_open_duration(config[CONF_OPEN_DURATION]))
    yield automation.build_automation(
        var.get_open_trigger(), [], config[CONF_OPEN_ACTION]
    )

    bin = yield cg.get_variable(config[CONF_CLOSE_ENDSTOP])
    cg.add(var.set_close_endstop(bin))
    cg.add(var.set_close_duration(config[CONF_CLOSE_DURATION]))
    yield automation.build_automation(
        var.get_close_trigger(), [], config[CONF_CLOSE_ACTION]
    )

    if CONF_MAX_DURATION in config:
        cg.add(var.set_max_duration(config[CONF_MAX_DURATION]))
Exemple #3
0
def to_code(config):
    var = cg.new_Pvariable(config[CONF_ID])
    yield cg.register_component(var, config)
    yield cover.register_cover(var, config)
    if CONF_LAMBDA in config:
        template_ = yield cg.process_lambda(
            config[CONF_LAMBDA], [], return_type=cg.optional.template(float))
        cg.add(var.set_state_lambda(template_))
    if CONF_OPEN_ACTION in config:
        yield automation.build_automation(var.get_open_trigger(), [],
                                          config[CONF_OPEN_ACTION])
    if CONF_CLOSE_ACTION in config:
        yield automation.build_automation(var.get_close_trigger(), [],
                                          config[CONF_CLOSE_ACTION])
    if CONF_STOP_ACTION in config:
        yield automation.build_automation(var.get_stop_trigger(), [],
                                          config[CONF_STOP_ACTION])
    if CONF_TILT_ACTION in config:
        yield automation.build_automation(var.get_tilt_trigger(),
                                          [(float, 'tilt')],
                                          config[CONF_TILT_ACTION])
        cg.add(var.set_has_tilt(True))
    if CONF_TILT_LAMBDA in config:
        tilt_template_ = yield cg.process_lambda(
            config[CONF_TILT_LAMBDA], [],
            return_type=cg.optional.template(float))
        cg.add(var.set_tilt_lambda(tilt_template_))

    cg.add(var.set_optimistic(config[CONF_OPTIMISTIC]))
    cg.add(var.set_assumed_state(config[CONF_ASSUMED_STATE]))
    cg.add(var.set_restore_mode(config[CONF_RESTORE_MODE]))
def to_code(config):
    template_ = yield cg.process_lambda(config[CONF_LAMBDA], [],
                                        return_type=cg.std_vector.template(
                                            cover.Cover.operator('ptr')))

    rhs = CustomCoverConstructor(template_)
    custom = cg.variable(config[CONF_ID], rhs)
    for i, conf in enumerate(config[CONF_COVERS]):
        rhs = custom.Pget_cover(i)
        yield cover.register_cover(rhs, conf)
Exemple #5
0
def to_code(config):
    var = cg.new_Pvariable(config[CONF_ID])
    yield cg.register_component(var, config)
    yield cover.register_cover(var, config)

    yield automation.build_automation(var.get_stop_trigger(), [], config[CONF_STOP_ACTION])

    cg.add(var.set_open_duration(config[CONF_OPEN_DURATION]))
    yield automation.build_automation(var.get_open_trigger(), [], config[CONF_OPEN_ACTION])

    cg.add(var.set_close_duration(config[CONF_CLOSE_DURATION]))
    yield automation.build_automation(var.get_close_trigger(), [], config[CONF_CLOSE_ACTION])
Exemple #6
0
def to_code(config):
    var = cg.new_Pvariable(config[CONF_ID])
    yield cg.register_component(var, config)
    yield cover.register_cover(var, config)

    yield automation.build_automation(var.get_stop_trigger(), [], config[CONF_STOP_ACTION])

    cg.add(var.set_open_duration(config[CONF_OPEN_DURATION]))
    yield automation.build_automation(var.get_open_trigger(), [], config[CONF_OPEN_ACTION])

    cg.add(var.set_close_duration(config[CONF_CLOSE_DURATION]))
    yield automation.build_automation(var.get_close_trigger(), [], config[CONF_CLOSE_ACTION])

    cg.add(var.set_has_built_in_endstop(config[CONF_HAS_BUILT_IN_ENDSTOP]))
    cg.add(var.set_assumed_state(config[CONF_ASSUMED_STATE]))
def to_code(config):
    var = cg.new_Pvariable(config[CONF_ID])
    yield cg.register_component(var, config)
    yield cover.register_cover(var, config)