Example #1
0
def to_code(config):
    cg.variable(
        config[CONF_ID],
        cg.StructInitializer(ColorStruct, ('r', config[CONF_RED]),
                             ('g', config[CONF_GREEN]),
                             ('b', config[CONF_BLUE]),
                             ('w', config[CONF_WHITE])))
Example #2
0
def to_code(config):
    template_ = yield cg.process_lambda(
        config[CONF_LAMBDA], [], return_type=cg.std_vector.template(switch.SwitchPtr))

    rhs = CustomSwitchConstructor(template_)
    var = cg.variable(config[CONF_ID], rhs)
    for i, conf in enumerate(config[CONF_SWITCHES]):
        switch_ = cg.Pvariable(conf[CONF_ID], var.get_switch(i))
        yield switch.register_switch(switch_, conf)
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)
def to_code(config):
    template_ = yield cg.process_lambda(config[CONF_LAMBDA], [],
                                        return_type=cg.std_vector.template(
                                            cg.ComponentPtr))

    rhs = CustomComponentConstructor(template_)
    var = cg.variable(config[CONF_ID], rhs)
    for i, conf in enumerate(config.get(CONF_COMPONENTS, [])):
        comp = cg.Pvariable(conf[CONF_ID], var.get_component(i))
        yield cg.register_component(comp, conf)
Example #5
0
def to_code(config):
    template_ = yield cg.process_lambda(config[CONF_LAMBDA], [],
                                        return_type=cg.std_vector.template(
                                            light.LightOutput.operator('ptr')))

    rhs = CustomLightOutputConstructor(template_)
    custom = cg.variable(config[CONF_ID], rhs)
    for i, conf in enumerate(config[CONF_LIGHTS]):
        rhs = custom.Pget_light(i)
        yield light.register_light(rhs, conf)
def to_code(config):
    template_ = yield cg.process_lambda(config[CONF_LAMBDA], [],
                                        return_type=cg.std_vector.template(
                                            sensor.SensorPtr))

    rhs = CustomSensorConstructor(template_)
    var = cg.variable(config[CONF_ID], rhs)
    for i, conf in enumerate(config[CONF_SENSORS]):
        sens = cg.Pvariable(conf[CONF_ID], var.get_sensor(i))
        yield sensor.register_sensor(sens, conf)
Example #7
0
def to_code(config):
    template_ = yield cg.process_lambda(
        config[CONF_LAMBDA],
        [],
        return_type=cg.std_vector.template(binary_sensor.BinarySensorPtr),
    )

    rhs = CustomBinarySensorConstructor(template_)
    custom = cg.variable(config[CONF_ID], rhs)
    for i, conf in enumerate(config[CONF_BINARY_SENSORS]):
        rhs = custom.Pget_binary_sensor(i)
        yield binary_sensor.register_binary_sensor(rhs, conf)
Example #8
0
async def to_code(config):
    template_ = await cg.process_lambda(
        config[CONF_LAMBDA],
        [],
        return_type=cg.std_vector.template(climate.Climate.operator("ptr")),
    )

    rhs = CustomClimateConstructor(template_)
    custom = cg.variable(config[CONF_ID], rhs)
    for i, conf in enumerate(config[CONF_CLIMATES]):
        rhs = custom.Pget_climate(i)
        await climate.register_climate(rhs, conf)
Example #9
0
async def to_code(config):
    template_ = await cg.process_lambda(
        config[CONF_LAMBDA],
        [],
        return_type=cg.std_vector.template(text_sensor.TextSensorPtr),
    )

    rhs = CustomTextSensorConstructor(template_)
    var = cg.variable(config[CONF_ID], rhs)

    for i, conf in enumerate(config[CONF_TEXT_SENSORS]):
        text = cg.Pvariable(conf[CONF_ID], var.get_text_sensor(i))
        await text_sensor.register_text_sensor(text, conf)
Example #10
0
def to_code(config):
    type = config[CONF_TYPE]
    if type == "binary":
        ret_type = output.BinaryOutputPtr
        klass = CustomBinaryOutputConstructor
    else:
        ret_type = output.FloatOutputPtr
        klass = CustomFloatOutputConstructor
    template_ = yield cg.process_lambda(
        config[CONF_LAMBDA], [], return_type=cg.std_vector.template(ret_type))

    rhs = klass(template_)
    custom = cg.variable(config[CONF_ID], rhs)
    for i, conf in enumerate(config[CONF_OUTPUTS]):
        out = cg.Pvariable(conf[CONF_ID], custom.get_output(i))
        yield output.register_output(out, conf)
Example #11
0
def wifi_network(config, static_ip):
    ap = cg.variable(config[CONF_ID], WiFiAP())
    if CONF_SSID in config:
        cg.add(ap.set_ssid(config[CONF_SSID]))
    if CONF_PASSWORD in config:
        cg.add(ap.set_password(config[CONF_PASSWORD]))
    if CONF_BSSID in config:
        cg.add(ap.set_bssid([HexInt(i) for i in config[CONF_BSSID].parts]))
    if CONF_HIDDEN in config:
        cg.add(ap.set_hidden(config[CONF_HIDDEN]))
    if CONF_CHANNEL in config:
        cg.add(ap.set_channel(config[CONF_CHANNEL]))
    if static_ip is not None:
        cg.add(ap.set_manual_ip(manual_ip(static_ip)))

    return ap
Example #12
0
def wifi_network(config, static_ip):
    ap = cg.variable(config[CONF_ID], WiFiAP())
    if CONF_SSID in config:
        cg.add(ap.set_ssid(config[CONF_SSID]))
    if CONF_PASSWORD in config:
        cg.add(ap.set_password(config[CONF_PASSWORD]))
    if CONF_EAP in config:
        cg.add(ap.set_eap(eap_auth(config[CONF_EAP])))
        cg.add_define("ESPHOME_WIFI_WPA2_EAP")
    if CONF_BSSID in config:
        cg.add(ap.set_bssid([HexInt(i) for i in config[CONF_BSSID].parts]))
    if CONF_HIDDEN in config:
        cg.add(ap.set_hidden(config[CONF_HIDDEN]))
    if CONF_CHANNEL in config:
        cg.add(ap.set_channel(config[CONF_CHANNEL]))
    if static_ip is not None:
        cg.add(ap.set_manual_ip(manual_ip(static_ip)))
    if CONF_PRIORITY in config:
        cg.add(ap.set_priority(config[CONF_PRIORITY]))

    return ap