Exemple #1
0
def to_code(config):
    rhs = App.make_fast_led_light(config[CONF_NAME])
    make = variable(config[CONF_MAKE_ID], rhs)
    fast_led = make.Pfast_led

    rgb_order = None
    if CONF_RGB_ORDER in config:
        rgb_order = RawExpression(config[CONF_RGB_ORDER])
    template_args = TemplateArguments(RawExpression(config[CONF_CHIPSET]),
                                      config[CONF_DATA_PIN],
                                      config[CONF_CLOCK_PIN], rgb_order)
    add(fast_led.add_leds(template_args, config[CONF_NUM_LEDS]))

    if CONF_MAX_REFRESH_RATE in config:
        add(fast_led.set_max_refresh_rate(config[CONF_MAX_REFRESH_RATE]))

    if CONF_POWER_SUPPLY in config:
        for power_supply in get_variable(config[CONF_POWER_SUPPLY]):
            yield
        add(fast_led.set_power_supply(power_supply))

    if CONF_COLOR_CORRECT in config:
        r, g, b = config[CONF_COLOR_CORRECT]
        add(fast_led.set_correction(r, g, b))

    light.setup_light(make.Pstate, make.Pmqtt, config)
    setup_component(fast_led, config)
def to_code(config):
    output = None
    for output in get_variable(config[CONF_OUTPUT]):
        yield
    rhs = App.make_monochromatic_light(config[CONF_NAME], output)
    light_struct = variable(config[CONF_MAKE_ID], rhs)
    light.setup_light(light_struct.Pstate, light_struct.Pmqtt, config)
Exemple #3
0
def to_code(config):
    for output_ in get_variable(config[CONF_OUTPUT]):
        yield
    rhs = App.make_binary_light(config[CONF_NAME], output_)
    light_struct = variable(config[CONF_MAKE_ID], rhs)
    light.setup_light(light_struct.Pstate, light_struct.Pmqtt, config)
    setup_component(light_struct.Pstate, config)
Exemple #4
0
def to_code(config):
    red = get_variable(config[CONF_RED])
    green = get_variable(config[CONF_GREEN])
    blue = get_variable(config[CONF_BLUE])
    rhs = App.make_rgb_light(config[CONF_NAME], red, green, blue)
    light_struct = variable(light.MakeLight, config[CONF_MAKE_ID], rhs)
    light.setup_light(light_struct.Pstate, light_struct.Pmqtt, config)
Exemple #5
0
def to_code(config):
    for cold_white in get_variable(config[CONF_COLD_WHITE]):
        yield
    for warm_white in get_variable(config[CONF_WARM_WHITE]):
        yield
    rhs = App.make_cwww_light(config[CONF_NAME], config[CONF_COLD_WHITE_COLOR_TEMPERATURE],
                              config[CONF_WARM_WHITE_COLOR_TEMPERATURE],
                              cold_white, warm_white)
    light_struct = variable(config[CONF_MAKE_ID], rhs)
    light.setup_light(light_struct.Pstate, light_struct.Pmqtt, config)
Exemple #6
0
def to_code(config):
    for red in get_variable(config[CONF_RED]):
        yield
    for green in get_variable(config[CONF_GREEN]):
        yield
    for blue in get_variable(config[CONF_BLUE]):
        yield
    rhs = App.make_rgb_light(config[CONF_NAME], red, green, blue)
    light_struct = variable(config[CONF_MAKE_ID], rhs)
    light.setup_light(light_struct.Pstate, light_struct.Pmqtt, config)
    setup_component(light_struct.Pstate, config)
Exemple #7
0
def to_code(config):
    red = None
    for red in get_variable(config[CONF_RED]):
        yield
    green = None
    for green in get_variable(config[CONF_GREEN]):
        yield
    blue = None
    for blue in get_variable(config[CONF_BLUE]):
        yield
    white = None
    for white in get_variable(config[CONF_WHITE]):
        yield
    rhs = App.make_rgbw_light(config[CONF_NAME], red, green, blue, white)
    light_struct = variable(config[CONF_MAKE_ID], rhs)
    light.setup_light(light_struct.Pstate, light_struct.Pmqtt, config)
Exemple #8
0
def to_code(config):
    for red in get_variable(config[CONF_RED]):
        yield
    for green in get_variable(config[CONF_GREEN]):
        yield
    for blue in get_variable(config[CONF_BLUE]):
        yield
    for cold_white in get_variable(config[CONF_COLD_WHITE]):
        yield
    for warm_white in get_variable(config[CONF_WARM_WHITE]):
        yield
    rhs = App.make_rgbww_light(config[CONF_NAME],
                               config[CONF_COLD_WHITE_COLOR_TEMPERATURE],
                               config[CONF_WARM_WHITE_COLOR_TEMPERATURE], red,
                               green, blue, cold_white, warm_white)
    light_struct = variable(config[CONF_MAKE_ID], rhs)
    light.setup_light(light_struct.Pstate, light_struct.Pmqtt, config)
Exemple #9
0
def to_code(config):
    rhs = App.make_fast_led_light(config[CONF_NAME])
    make = variable(MakeFastLEDLight, config[CONF_MAKE_ID], rhs)
    fast_led = make.Pfast_led

    rgb_order = None
    if CONF_RGB_ORDER in config:
        rgb_order = RawExpression(config[CONF_RGB_ORDER])
    template_args = TemplateArguments(RawExpression(config[CONF_CHIPSET]),
                                      config[CONF_PIN], rgb_order)
    add(fast_led.add_leds(template_args, config[CONF_NUM_LEDS]))

    if CONF_MAX_REFRESH_RATE in config:
        add(fast_led.set_max_refresh_rate(config[CONF_MAX_REFRESH_RATE]))

    if CONF_POWER_SUPPLY in config:
        power_supply = get_variable(config[CONF_POWER_SUPPLY])
        add(fast_led.set_power_supply(power_supply))

    light.setup_light(make.Pstate, make.Pmqtt, config)
Exemple #10
0
def to_code(config):
    type_ = config[CONF_TYPE]
    has_white = 'W' in type_
    if has_white:
        func = App.make_neo_pixel_bus_rgbw_light
        color_feat = global_ns.NeoRgbwFeature
    else:
        func = App.make_neo_pixel_bus_rgb_light
        color_feat = global_ns.NeoRgbFeature

    template = TemplateArguments(getattr(global_ns, format_method(config)),
                                 color_feat)
    rhs = func(template, config[CONF_NAME])
    make = variable(config[CONF_MAKE_ID],
                    rhs,
                    type=MakeNeoPixelBusLight.template(template))
    output = make.Poutput

    if CONF_PIN in config:
        add(output.add_leds(config[CONF_NUM_LEDS], config[CONF_PIN]))
    else:
        add(
            output.add_leds(config[CONF_NUM_LEDS], config[CONF_CLOCK_PIN],
                            config[CONF_DATA_PIN]))

    add(output.set_pixel_order(getattr(ESPNeoPixelOrder, type_)))

    if CONF_POWER_SUPPLY in config:
        for power_supply in get_variable(config[CONF_POWER_SUPPLY]):
            yield
        add(output.set_power_supply(power_supply))

    if CONF_COLOR_CORRECT in config:
        add(output.set_correction(*config[CONF_COLOR_CORRECT]))

    light.setup_light(make.Pstate, make.Pmqtt, config)
    setup_component(output, config)
Exemple #11
0
def to_code(config):
    output = get_variable(config[CONF_OUTPUT])
    rhs = App.make_binary_light(config[CONF_NAME], output)
    light_struct = variable(light.MakeLight, config[CONF_MAKE_ID], rhs)
    light.setup_light(light_struct.Pstate, light_struct.Pmqtt, config)