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, config) setup_component(fast_led, config)
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, config) setup_component(light_struct.Pstate, config)
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, config) setup_component(light_struct.Pstate, config)
def to_code(config): for template_ in process_lambda(config[CONF_LAMBDA], [], return_type=std_vector.template(binary_sensor.BinarySensorPtr)): yield rhs = CustomBinarySensorConstructor(template_) custom = variable(config[CONF_ID], rhs) for i, conf in enumerate(config[CONF_BINARY_SENSORS]): rhs = custom.Pget_binary_sensor(i) add(rhs.set_name(conf[CONF_NAME])) binary_sensor.register_binary_sensor(rhs, conf)
def to_code(config): for template_ in process_lambda( config[CONF_LAMBDA], [], return_type=std_vector.template(ComponentPtr)): yield rhs = CustomComponentConstructor(template_) custom = variable(config[CONF_ID], rhs) for i, comp_config in enumerate(config.get(CONF_COMPONENTS, [])): comp = Pvariable(comp_config[CONF_ID], custom.get_component(i)) setup_component(comp, comp_config)
def to_code(config): for template_ in process_lambda(config[CONF_LAMBDA], [], return_type=std_vector.template(switch.SwitchPtr)): yield rhs = CustomSwitchConstructor(template_) custom = variable(config[CONF_ID], rhs) for i, conf in enumerate(config[CONF_SWITCHES]): rhs = custom.Pget_switch(i) add(rhs.set_name(conf[CONF_NAME])) switch.register_switch(rhs, conf)
def to_code(config): segments = [] for conf in config[CONF_SEGMENTS]: for var in get_variable(conf[CONF_ID]): yield segments.append( AddressableSegment(var, conf[CONF_FROM], conf[CONF_TO] - conf[CONF_FROM] + 1)) rhs = App.make_partition_light(config[CONF_NAME], segments) make = variable(config[CONF_MAKE_ID], rhs) light.setup_light(make.Pstate, config)
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, config) setup_component(light_struct.Pstate, config)
def to_code(config): type = config[CONF_TYPE] if type == 'binary': ret_type = output.BinaryOutputPtr klass = CustomBinaryOutputConstructor else: ret_type = output.FloatOutputPtr klass = CustomFloatOutputConstructor for template_ in process_lambda(config[CONF_LAMBDA], [], return_type=std_vector.template(ret_type)): yield rhs = klass(template_) custom = variable(config[CONF_ID], rhs) for i, conf in enumerate(config[CONF_OUTPUTS]): output.register_output(custom.get_output(i), conf)
def wifi_network(config, static_ip): ap = variable(config[CONF_ID], WiFiAP()) if CONF_SSID in config: add(ap.set_ssid(config[CONF_SSID])) if CONF_PASSWORD in config: add(ap.set_password(config[CONF_PASSWORD])) if CONF_BSSID in config: add(ap.set_bssid([HexInt(i) for i in config[CONF_BSSID].parts])) if CONF_HIDDEN in config: add(ap.set_hidden(config[CONF_HIDDEN])) if CONF_CHANNEL in config: add(ap.set_channel(config[CONF_CHANNEL])) if static_ip is not None: add(ap.set_manual_ip(manual_ip(static_ip))) return ap
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, config) setup_component(light_struct.Pstate, config)
def to_code(config): for output_ in get_variable(config[CONF_OUTPUT]): yield rhs = App.make_fan(config[CONF_NAME]) fan_struct = variable(config[CONF_MAKE_ID], rhs) if CONF_SPEED in config: speeds = config[CONF_SPEED] add( fan_struct.Poutput.set_speed(output_, speeds[CONF_LOW], speeds[CONF_MEDIUM], speeds[CONF_HIGH])) else: add(fan_struct.Poutput.set_speed(output_)) if CONF_OSCILLATION_OUTPUT in config: for oscillation_output in get_variable( config[CONF_OSCILLATION_OUTPUT]): yield add(fan_struct.Poutput.set_oscillation(oscillation_output)) fan.setup_fan(fan_struct.Pstate, config)
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, config) setup_component(output, config)