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)
def to_code(config): power_supply = None if CONF_POWER_SUPPLY in config: power_supply = get_variable(config[CONF_POWER_SUPPLY]) pca9685 = get_variable(config.get(CONF_PCA9685_ID), PCA9685OutputComponent) rhs = pca9685.create_channel(config[CONF_CHANNEL], power_supply) out = Pvariable(Channel, config[CONF_ID], rhs) output.setup_output_platform(out, config, skip_power_supply=True)
def to_code(config): output = get_variable(config[CONF_OUTPUT]) rhs = App.make_fan(config[CONF_NAME]) fan_struct = variable('Application::MakeFan', config[CONF_ID], rhs) add(fan_struct.Poutput.set_binary(output)) if CONF_OSCILLATION_OUTPUT in config: oscillation_output = get_variable(config[CONF_OSCILLATION_OUTPUT]) add(fan_struct.Poutput.set_oscillation(oscillation_output)) fan.setup_mqtt_fan(fan_struct.Pmqtt, config)
def to_code(config): power_supply = None if CONF_POWER_SUPPLY in config: for power_supply in get_variable(config[CONF_POWER_SUPPLY]): yield for pca9685 in get_variable(config[CONF_PCA9685_ID]): yield rhs = pca9685.create_channel(config[CONF_CHANNEL], power_supply) out = Pvariable(config[CONF_ID], rhs) output.setup_output_platform(out, config, skip_power_supply=True)
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)
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('Application::MakeLight', config[CONF_ID], rhs) if CONF_GAMMA_CORRECT in config: add(light_struct.Poutput.set_gamma_correct(config[CONF_GAMMA_CORRECT])) setup_mqtt_component(light_struct.Pmqtt, config) light.setup_light_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, light_struct.Pmqtt, config) setup_component(light_struct.Pstate, config)
def to_code(config): for time_ in get_variable(config[CONF_TIME_ID]): yield for sens in get_variable(config[CONF_POWER_ID]): yield rhs = App.make_total_daily_energy_sensor(config[CONF_NAME], time_, sens) make = variable(config[CONF_MAKE_ID], rhs) total_energy = make.Ptotal_energy sensor.setup_sensor(total_energy, make.Pmqtt, config) setup_component(total_energy, config)
def to_code(config): power_supply = None if CONF_POWER_SUPPLY in config: for power_supply in get_variable(config[CONF_POWER_SUPPLY]): yield my9231 = None for my9231 in get_variable(config[CONF_MY9231_ID]): yield rhs = my9231.create_channel(config[CONF_CHANNEL], power_supply) out = Pvariable(config[CONF_ID], rhs) output.setup_output_platform(out, config, skip_power_supply=True) setup_component(out, 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) add(fan_struct.Poutput.set_binary(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, fan_struct.Pmqtt, config) setup_component(fan_struct.Poutput, config)
def deep_sleep_prevent_to_code(config, action_id, arg_type): template_arg = TemplateArguments(arg_type) for var in get_variable(config[CONF_ID]): yield None rhs = var.make_prevent_deep_sleep_action(template_arg) type = PreventDeepSleepAction.template(arg_type) yield Pvariable(action_id, rhs, type=type)
def to_code(config): hub = None for hub in get_variable(config[CONF_ESP32_BLE_ID]): yield rhs = hub.make_miflora_sensor(make_address_array(config[CONF_MAC_ADDRESS])) dev = Pvariable(config[CONF_MAKE_ID], rhs) if CONF_TEMPERATURE in config: conf = config[CONF_TEMPERATURE] sensor.register_sensor(dev.Pmake_temperature_sensor(conf[CONF_NAME]), conf) if CONF_MOISTURE in config: conf = config[CONF_MOISTURE] sensor.register_sensor(dev.Pmake_moisture_sensor(conf[CONF_NAME]), conf) if CONF_ILLUMINANCE in config: conf = config[CONF_ILLUMINANCE] sensor.register_sensor(dev.Pmake_illuminance_sensor(conf[CONF_NAME]), conf) if CONF_CONDUCTIVITY in config: conf = config[CONF_CONDUCTIVITY] sensor.register_sensor(dev.Pmake_conductivity_sensor(conf[CONF_NAME]), conf) if CONF_BATTERY_LEVEL in config: conf = config[CONF_BATTERY_LEVEL] sensor.register_sensor(dev.Pmake_battery_level_sensor(conf[CONF_NAME]), conf)
def to_code(config): for uart in get_variable(config[CONF_UART_ID]): yield rhs = App.make_pmsx003(uart, PMSX003_TYPES[config[CONF_TYPE]]) pms = Pvariable(config[CONF_ID], rhs) if CONF_PM_1_0 in config: conf = config[CONF_PM_1_0] sensor.register_sensor(pms.make_pm_1_0_sensor(conf[CONF_NAME]), conf) if CONF_PM_2_5 in config: conf = config[CONF_PM_2_5] sensor.register_sensor(pms.make_pm_2_5_sensor(conf[CONF_NAME]), conf) if CONF_PM_10_0 in config: conf = config[CONF_PM_10_0] sensor.register_sensor(pms.make_pm_10_0_sensor(conf[CONF_NAME]), conf) if CONF_TEMPERATURE in config: conf = config[CONF_TEMPERATURE] sensor.register_sensor(pms.make_temperature_sensor(conf[CONF_NAME]), conf) if CONF_HUMIDITY in config: conf = config[CONF_HUMIDITY] sensor.register_sensor(pms.make_humidity_sensor(conf[CONF_NAME]), conf) if CONF_FORMALDEHYDE in config: conf = config[CONF_FORMALDEHYDE] sensor.register_sensor(pms.make_formaldehyde_sensor(conf[CONF_NAME]), conf)
def to_code(config): for spi in get_variable(config[CONF_SPI_ID]): yield for cs in gpio_output_pin_expression(config[CONF_CS_PIN]): yield for dc in gpio_output_pin_expression(config[CONF_DC_PIN]): yield model_type, model = MODELS[config[CONF_MODEL]] if model_type == 'a': rhs = App.make_waveshare_epaper_type_a(spi, cs, dc, model) epaper = Pvariable(config[CONF_ID], rhs, type=WaveshareEPaperTypeA) elif model_type == 'b': rhs = App.make_waveshare_epaper_type_b(spi, cs, dc, model) epaper = Pvariable(config[CONF_ID], rhs, type=WaveshareEPaper) else: raise NotImplementedError() if CONF_LAMBDA in config: for lambda_ in process_lambda(config[CONF_LAMBDA], [(display.DisplayBufferRef, 'it')]): yield add(epaper.set_writer(lambda_)) if CONF_RESET_PIN in config: for reset in gpio_output_pin_expression(config[CONF_RESET_PIN]): yield add(epaper.set_reset_pin(reset)) if CONF_BUSY_PIN in config: for reset in gpio_input_pin_expression(config[CONF_BUSY_PIN]): yield add(epaper.set_busy_pin(reset)) if CONF_FULL_UPDATE_EVERY in config: add(epaper.set_full_update_every(config[CONF_FULL_UPDATE_EVERY])) display.setup_display(epaper, config)
def fan_toggle_to_code(config, action_id, arg_type): template_arg = TemplateArguments(arg_type) for var in get_variable(config[CONF_ID]): yield None rhs = var.make_toggle_action(template_arg) type = ToggleAction.template(arg_type) yield Pvariable(action_id, rhs, type=type)
def to_code(config): for conf in config: for uart_ in get_variable(conf[CONF_UART_ID]): yield rhs = App.make_rdm6300_component(uart_) var = Pvariable(conf[CONF_ID], rhs) setup_component(var, conf)
def to_code(config): output = None for output in get_variable(config[CONF_OUTPUT]): yield rhs = App.make_simple_switch(config[CONF_NAME], output) gpio = variable(config[CONF_MAKE_ID], rhs) switch.setup_switch(gpio.Pswitch_, gpio.Pmqtt, 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, light_struct.Pmqtt, config) setup_component(light_struct.Pstate, config)
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)
def to_code(config): ir = None for ir in get_variable(config[CONF_IR_TRANSMITTER_ID]): yield send_data = exp_send_data(config) rhs = App.register_component(ir.create_transmitter(config[CONF_NAME], send_data)) switch.register_switch(rhs, config)
def to_code(config): hub = None for hub in get_variable(config[CONF_NEXTION_ID]): yield rhs = hub.make_touch_component(config[CONF_NAME], config[CONF_PAGE_ID], config[CONF_COMPONENT_ID]) binary_sensor.register_binary_sensor(rhs, config)
def to_code(config): ir = get_variable(config.get(CONF_IR_TRANSMITTER_ID), IRTransmitterComponent) send_data = exp_send_data(config) rhs = App.register_component( ir.create_transmitter(config[CONF_NAME], send_data)) switch.register_switch(rhs, config)
def to_code(config): for remote in get_variable(config[CONF_REMOTE_RECEIVER_ID]): yield rhs = receiver_base(config) receiver = Pvariable(config[CONF_RECEIVER_ID], rhs) binary_sensor.register_binary_sensor(remote.add_decoder(receiver), config)
def to_code(config): for hub in get_variable(config[CONF_PN532_ID]): yield addr = [HexInt(int(x, 16)) for x in config[CONF_UID].split('-')] rhs = hub.make_tag(config[CONF_NAME], ArrayInitializer(*addr, multiline=False)) binary_sensor.register_binary_sensor(rhs, config)
def switch_turn_off_to_code(config, action_id, arg_type): template_arg = TemplateArguments(arg_type) for var in get_variable(config[CONF_ID]): yield None rhs = var.make_turn_off_action(template_arg) type = TurnOffAction.template(arg_type) yield Pvariable(action_id, rhs, type=type)
def to_code(config): for spi_ in get_variable(config[CONF_SPI_ID]): yield for cs in gpio_output_pin_expression(config[CONF_CS_PIN]): yield for dc in gpio_output_pin_expression(config[CONF_DC_PIN]): yield rhs = App.make_spi_ssd1306(spi_, cs, dc) ssd = Pvariable(config[CONF_ID], rhs) add(ssd.set_model(MODELS[config[CONF_MODEL]])) if CONF_RESET_PIN in config: for reset in gpio_output_pin_expression(config[CONF_RESET_PIN]): yield add(ssd.set_reset_pin(reset)) if CONF_EXTERNAL_VCC in config: add(ssd.set_external_vcc(config[CONF_EXTERNAL_VCC])) if CONF_LAMBDA in config: for lambda_ in process_lambda(config[CONF_LAMBDA], [(display.DisplayBufferRef, 'it')]): yield add(ssd.set_writer(lambda_)) display.setup_display(ssd, config) setup_component(ssd, 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)
def to_code(config): hub = None for hub in get_variable(config[CONF_ESP32_BLE_ID]): yield rhs = hub.make_presence_sensor( config[CONF_NAME], make_address_array(config[CONF_MAC_ADDRESS])) binary_sensor.register_binary_sensor(rhs, config)
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): hub = get_variable(config.get(CONF_ADS1115_ID), ADS1115Component) mux = MUX[config[CONF_MULTIPLEXER]] gain = GAIN[config[CONF_GAIN]] rhs = hub.get_sensor(config[CONF_NAME], mux, gain, config.get(CONF_UPDATE_INTERVAL)) sensor.register_sensor(rhs, config)