예제 #1
0
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)
예제 #2
0
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)
예제 #3
0
def to_code(config):
    rhs = App.make_gpio_lcd_display(config[CONF_DIMENSIONS][0], config[CONF_DIMENSIONS][1])
    lcd = Pvariable(config[CONF_ID], rhs)
    pins_ = []
    for conf in config[CONF_DATA_PINS]:
        for pin in gpio_output_pin_expression(conf):
            yield
        pins_.append(pin)
    add(lcd.set_data_pins(*pins_))
    for enable in gpio_output_pin_expression(config[CONF_ENABLE_PIN]):
        yield
    add(lcd.set_enable_pin(enable))

    for rs in gpio_output_pin_expression(config[CONF_RS_PIN]):
        yield
    add(lcd.set_rs_pin(rs))

    if CONF_RW_PIN in config:
        for rw in gpio_output_pin_expression(config[CONF_RW_PIN]):
            yield
        add(lcd.set_rw_pin(rw))

    if CONF_LAMBDA in config:
        for lambda_ in process_lambda(config[CONF_LAMBDA], [(LCDDisplayRef, 'it')]):
            yield
        add(lcd.set_writer(lambda_))

    display.setup_display(lcd, config)
예제 #4
0
파일: max6675.py 프로젝트: brandond/esphome
def to_code(config):
    pin_cs = gpio_output_pin_expression(config[CONF_PIN_CS])
    pin_clock = gpio_output_pin_expression(config[CONF_PIN_CLOCK])
    pin_miso = gpio_input_pin_expression(config[CONF_PIN_MISO])
    rhs = App.make_max6675_sensor(config[CONF_NAME], pin_cs, pin_clock,
                                  pin_miso, config.get(CONF_UPDATE_INTERVAL))
    make = variable(MakeMAX6675Sensor, config[CONF_MAKE_ID], rhs)
    sensor.setup_sensor(make.Pmax6675, make.Pmqtt, config)
예제 #5
0
def to_code(config):
    for step_pin in gpio_output_pin_expression(config[CONF_STEP_PIN]):
        yield
    for dir_pin in gpio_output_pin_expression(config[CONF_DIR_PIN]):
        yield
    rhs = App.make_a4988(step_pin, dir_pin)
    a4988 = Pvariable(config[CONF_ID], rhs)

    if CONF_SLEEP_PIN in config:
        for sleep_pin in gpio_output_pin_expression(config[CONF_SLEEP_PIN]):
            yield
        add(a4988.set_sleep_pin(sleep_pin))

    stepper.setup_stepper(a4988, config)
    setup_component(a4988, config)
예제 #6
0
def to_code(config):
    for pin in gpio_output_pin_expression(config[CONF_PIN]):
        yield
    rhs = App.make_gpio_output(pin)
    gpio = Pvariable(config[CONF_ID], rhs)
    output.setup_output_platform(gpio, config)
    setup_component(gpio, config)
예제 #7
0
def to_code(config):
    for conf in config:
        pin = None
        for pin in gpio_output_pin_expression(conf[CONF_PIN]):
            yield
        rhs = App.make_ir_transmitter(pin, conf.get(CONF_CARRIER_DUTY_PERCENT))
        Pvariable(conf[CONF_ID], rhs)
예제 #8
0
파일: gpio.py 프로젝트: apeeters/esphome
def to_code(config):
    pin = None
    for pin in gpio_output_pin_expression(config[CONF_PIN]):
        yield
    rhs = App.make_gpio_switch(config[CONF_NAME], pin)
    gpio = variable(config[CONF_MAKE_ID], rhs)
    switch.setup_switch(gpio.Pswitch_, gpio.Pmqtt, config)
예제 #9
0
def to_code(config):
    pin = None
    for pin in gpio_output_pin_expression(config[CONF_PIN]):
        yield
    rhs = App.make_esp8266_pwm_output(pin)
    gpio = Pvariable(config[CONF_ID], rhs)
    output.setup_output_platform(gpio, config)
예제 #10
0
def to_code(config):
    for pin in gpio_output_pin_expression(config[CONF_PIN]):
        yield
    rhs = App.make_status_led(pin)
    var = Pvariable(config[CONF_ID], rhs)

    setup_component(var, config)
예제 #11
0
def to_code(config):
    for conf in config:
        rhs = App.make_power_supply(gpio_output_pin_expression(conf[CONF_PIN]))
        psu = Pvariable(PowerSupplyComponent, conf[CONF_ID], rhs)
        if CONF_ENABLE_TIME in conf:
            add(psu.set_enable_time(conf[CONF_ENABLE_TIME]))
        if CONF_KEEP_ON_TIME in conf:
            add(psu.set_keep_on_time(conf[CONF_KEEP_ON_TIME]))
예제 #12
0
def to_code(config):
    for pin in gpio_output_pin_expression(config[CONF_PIN]):
        yield
    rhs = App.make_gpio_switch(config[CONF_NAME], pin)
    make = variable(config[CONF_MAKE_ID], rhs)
    gpio = make.Pswitch_

    switch.setup_switch(gpio, make.Pmqtt, config)
    setup_component(gpio, config)
예제 #13
0
def to_code(config):
    for conf in config:
        di = None
        for di in gpio_output_pin_expression(conf[CONF_DATA_PIN]):
            yield
        dcki = None
        for dcki in gpio_output_pin_expression(conf[CONF_CLOCK_PIN]):
            yield
        rhs = App.make_my9231_component(di, dcki)
        my9231 = Pvariable(conf[CONF_ID], rhs)
        if CONF_NUM_CHANNELS in conf:
            add(my9231.set_num_channels(conf[CONF_NUM_CHANNELS]))
        if CONF_NUM_CHIPS in conf:
            add(my9231.set_num_chips(conf[CONF_NUM_CHIPS]))
        if CONF_BIT_DEPTH in conf:
            add(my9231.set_bit_depth(conf[CONF_BIT_DEPTH]))
        if CONF_UPDATE_ON_BOOT in conf:
            add(my9231.set_update(conf[CONF_UPDATE_ON_BOOT]))
        setup_component(my9231, conf)
예제 #14
0
def to_code(config):
    for conf in config:
        pin = None
        for pin in gpio_output_pin_expression(conf[CONF_PIN]):
            yield
        rhs = App.make_power_supply(pin)
        psu = Pvariable(conf[CONF_ID], rhs)
        if CONF_ENABLE_TIME in conf:
            add(psu.set_enable_time(conf[CONF_ENABLE_TIME]))
        if CONF_KEEP_ON_TIME in conf:
            add(psu.set_keep_on_time(conf[CONF_KEEP_ON_TIME]))
예제 #15
0
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
    rhs = App.make_max6675_sensor(config[CONF_NAME], spi_, cs,
                                  config.get(CONF_UPDATE_INTERVAL))
    make = variable(config[CONF_MAKE_ID], rhs)
    max6675 = make.Pmax6675
    sensor.setup_sensor(max6675, make.Pmqtt, config)
    setup_component(max6675, config)
예제 #16
0
def to_code(config):
    for pin in gpio_output_pin_expression(config[CONF_PIN]):
        yield
    rhs = App.make_esp8266_pwm_output(pin)
    gpio = Pvariable(config[CONF_ID], rhs)

    if CONF_FREQUENCY in config:
        add(gpio.set_frequency(config[CONF_FREQUENCY]))

    output.setup_output_platform(gpio, config)
    setup_component(gpio, config)
예제 #17
0
def to_code(config):
    pin = None
    for pin in gpio_output_pin_expression(config[CONF_PIN]):
        yield
    rhs = App.make_gpio_switch(config[CONF_NAME], pin)
    gpio = variable(config[CONF_MAKE_ID], rhs)

    if CONF_POWER_ON_VALUE in config:
        add(gpio.Pswitch_.set_power_on_value(config[CONF_POWER_ON_VALUE]))

    switch.setup_switch(gpio.Pswitch_, gpio.Pmqtt, config)
예제 #18
0
def to_code(config):
    for conf in config:
        pin = None
        for pin in gpio_output_pin_expression(conf[CONF_PIN]):
            yield
        rhs = App.make_remote_transmitter_component(pin)
        transmitter = Pvariable(conf[CONF_ID], rhs)
        if CONF_CARRIER_DUTY_PERCENT in conf:
            add(
                transmitter.set_carrier_duty_percent(
                    conf[CONF_CARRIER_DUTY_PERCENT]))
예제 #19
0
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]))

    display.setup_display(ssd, config)
예제 #20
0
def to_code(config):
    trigger = gpio_output_pin_expression(config[CONF_TRIGGER_PIN])
    echo = gpio_input_pin_expression(config[CONF_ECHO_PIN])
    rhs = App.make_ultrasonic_sensor(config[CONF_NAME], trigger, echo,
                                     config.get(CONF_UPDATE_INTERVAL))
    make = variable(MakeUltrasonicSensor, config[CONF_MAKE_ID], rhs)
    ultrasonic = make.Pultrasonic
    if CONF_TIMEOUT_TIME in config:
        add(ultrasonic.set_timeout_us(config[CONF_TIMEOUT_TIME]))
    elif CONF_TIMEOUT_METER in config:
        add(ultrasonic.set_timeout_m(config[CONF_TIMEOUT_METER]))
    sensor.setup_sensor(ultrasonic, make.Pmqtt, config)
예제 #21
0
def to_code(config):
    ssd = Pvariable(config[CONF_ID], App.make_i2c_ssd1306())
    add(ssd.set_model(ssd1306_spi.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_ADDRESS in config:
        add(ssd.set_address(config[CONF_ADDRESS]))

    display.setup_display(ssd, config)
예제 #22
0
def to_code(config):
    for conf in config:
        spi = None
        for spi in get_variable(conf[CONF_SPI_ID]):
            yield
        cs = None
        for cs in gpio_output_pin_expression(conf[CONF_CS_PIN]):
            yield
        rhs = App.make_pn532_component(spi, cs, conf.get(CONF_UPDATE_INTERVAL))
        pn532 = Pvariable(conf[CONF_ID], rhs)

        for conf_ in conf.get(CONF_ON_TAG, []):
            trigger = Pvariable(conf_[CONF_TRIGGER_ID], pn532.make_trigger())
            automation.build_automation(trigger, std_string, conf_)
예제 #23
0
def to_code(config):
    pin = gpio_output_pin_expression(config[CONF_PIN])
    rhs = App.make_dht_sensor(config[CONF_TEMPERATURE][CONF_NAME],
                              config[CONF_HUMIDITY][CONF_NAME], pin,
                              config.get(CONF_UPDATE_INTERVAL))
    dht = variable(MakeDHTSensor, config[CONF_MAKE_ID], rhs)
    if CONF_MODEL in config:
        constant = DHT_MODELS[config[CONF_MODEL]]
        add(dht.Pdht.set_dht_model(constant))

    sensor.setup_sensor(dht.Pdht.Pget_temperature_sensor(),
                        dht.Pmqtt_temperature, config[CONF_TEMPERATURE])
    sensor.setup_sensor(dht.Pdht.Pget_humidity_sensor(), dht.Pmqtt_humidity,
                        config[CONF_HUMIDITY])
예제 #24
0
def to_code(config):
    for conf in config:
        clk = None
        for clk in gpio_output_pin_expression(conf[CONF_CLK_PIN]):
            yield
        rhs = App.init_spi(clk)
        spi = Pvariable(conf[CONF_ID], rhs)
        if CONF_MISO_PIN in conf:
            for miso in gpio_input_pin_expression(conf[CONF_MISO_PIN]):
                yield
            add(spi.set_miso(miso))
        if CONF_MOSI_PIN in conf:
            for mosi in gpio_input_pin_expression(conf[CONF_MOSI_PIN]):
                yield
            add(spi.set_mosi(mosi))
예제 #25
0
def to_code(config):
    for pin in gpio_output_pin_expression(config[CONF_PIN]):
        yield
    rhs = App.make_dht_sensor(config[CONF_TEMPERATURE][CONF_NAME],
                              config[CONF_HUMIDITY][CONF_NAME], pin,
                              config.get(CONF_UPDATE_INTERVAL))
    make = variable(config[CONF_MAKE_ID], rhs)
    dht = make.Pdht
    Pvariable(config[CONF_ID], dht)

    if CONF_MODEL in config:
        constant = DHT_MODELS[config[CONF_MODEL]]
        add(dht.set_dht_model(constant))

    sensor.setup_sensor(dht.Pget_temperature_sensor(), make.Pmqtt_temperature,
                        config[CONF_TEMPERATURE])
    sensor.setup_sensor(dht.Pget_humidity_sensor(), make.Pmqtt_humidity,
                        config[CONF_HUMIDITY])
    setup_component(dht, config)
예제 #26
0
def to_code(config):
    ssd = Pvariable(config[CONF_ID], App.make_i2c_ssd1306())
    add(ssd.set_model(ssd1306_spi.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_ADDRESS in config:
        add(ssd.set_address(config[CONF_ADDRESS]))
    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)
예제 #27
0
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
    rhs = App.make_max7219(spi, cs)
    max7219 = Pvariable(config[CONF_ID], rhs)

    if CONF_NUM_CHIPS in config:
        add(max7219.set_num_chips(config[CONF_NUM_CHIPS]))
    if CONF_INTENSITY in config:
        add(max7219.set_intensity(config[CONF_INTENSITY]))

    if CONF_LAMBDA in config:
        for lambda_ in process_lambda(config[CONF_LAMBDA],
                                      [(MAX7219ComponentRef, 'it')]):
            yield
        add(max7219.set_writer(lambda_))

    display.setup_display(max7219, config)
예제 #28
0
def to_code(config):
    sel = None
    for sel in gpio_output_pin_expression(config[CONF_SEL_PIN]):
        yield

    rhs = App.make_hlw8012(sel, config[CONF_CF_PIN], config[CONF_CF1_PIN],
                           config.get(CONF_UPDATE_INTERVAL))
    hlw = Pvariable(config[CONF_ID], rhs)

    if CONF_VOLTAGE in config:
        conf = config[CONF_VOLTAGE]
        sensor.register_sensor(hlw.make_voltage_sensor(conf[CONF_NAME]), conf)
    if CONF_CURRENT in config:
        conf = config[CONF_CURRENT]
        sensor.register_sensor(hlw.make_current_sensor(conf[CONF_NAME]), conf)
    if CONF_POWER in config:
        conf = config[CONF_POWER]
        sensor.register_sensor(hlw.make_power_sensor(conf[CONF_NAME]), conf)
    if CONF_CURRENT_RESISTOR in config:
        add(hlw.set_current_resistor(config[CONF_CURRENT_RESISTOR]))
    if CONF_CHANGE_MODE_EVERY in config:
        add(hlw.set_change_mode_every(config[CONF_CHANGE_MODE_EVERY]))
예제 #29
0
파일: gpio.py 프로젝트: brandond/esphome
def to_code(config):
    pin = gpio_output_pin_expression(config[CONF_PIN])
    rhs = App.make_gpio_output(pin)
    gpio = Pvariable(GPIOBinaryOutputComponent, config[CONF_ID], rhs)
    output.setup_output_platform(gpio, config)
예제 #30
0
def to_code(config):
    pin = None
    for pin in gpio_output_pin_expression(config[CONF_PIN]):
        yield
    rhs = App.make_status_led(pin)
    Pvariable(config[CONF_ID], rhs)