Ejemplo n.º 1
0
def to_code(config):
    var = cg.new_Pvariable(config[CONF_ID])
    yield cg.register_component(var, config)

    pin = yield gpio_pin_expression(config[CONF_PIN])
    pin_out = yield gpio_pin_expression(config[CONF_PIN_A])

    cg.add(var.set_pin(pin, pin_out))

    if CONF_TEMPERATURE in config:
        sens = yield sensor.new_sensor(config[CONF_TEMPERATURE])
        cg.add(var.set_temperature_sensor(sens))
    if CONF_HUMIDITY in config:
        sens = yield sensor.new_sensor(config[CONF_HUMIDITY])
        cg.add(var.set_humidity_sensor(sens))

    cg.add(var.set_dht_model(config[CONF_MODEL]))
Ejemplo n.º 2
0
def to_code(config):
    var = cg.new_Pvariable(config[CONF_ID])
    yield cg.register_component(var, config)

    pin_clock = yield gpio_pin_expression(config[CONF_CLOCK_PIN])
    cg.add(var.set_pin_clock(pin_clock))
    pin_data = yield gpio_pin_expression(config[CONF_DATA_PIN])
    cg.add(var.set_pin_data(pin_data))

    if CONF_CO2 in config:
        sens = yield sensor.new_sensor(config[CONF_CO2])
        cg.add(var.set_co2_sensor(sens))
    if CONF_TEMPERATURE in config:
        sens = yield sensor.new_sensor(config[CONF_TEMPERATURE])
        cg.add(var.set_temperature_sensor(sens))
    if CONF_HUMIDITY in config:
        sens = yield sensor.new_sensor(config[CONF_HUMIDITY])
        cg.add(var.set_humidity_sensor(sens))
Ejemplo n.º 3
0
def test_gpio_pin_expression__new_pin(monkeypatch):
    target = ch.gpio_pin_expression({
        const.CONF_NUMBER: 42,
        const.CONF_MODE: "input",
        const.CONF_INVERTED: False
    })

    actual = next(target)

    assert isinstance(actual, MockObj)
Ejemplo n.º 4
0
def to_code(config):
    var = cg.new_Pvariable(config[CONF_ID])
    cg.add_library('IRRemoteESP8266',
                   None)  # cg.add_library('IRRemoteESP8266', '2.7.7')
    yield cg.register_component(var, config)
    yield climate.register_climate(var, config)

    # cg.add(var.set_pin(config[CONF_PIN]))
    pin = yield gpio_pin_expression(config[CONF_PIN])
    cg.add(var.set_pin(pin))

    if CONF_SENSOR in config:
        sens = yield cg.get_variable(config[CONF_SENSOR])
        cg.add(var.set_sensor(sens))
Ejemplo n.º 5
0
def test_gpio_pin_expression__conf_is_none(monkeypatch):
    target = ch.gpio_pin_expression(None)

    actual = next(target)

    assert actual is None