示例#1
0
def to_code(config):
    rhs = App.make_bme280_sensor(config[CONF_TEMPERATURE][CONF_NAME],
                                 config[CONF_PRESSURE][CONF_NAME],
                                 config[CONF_HUMIDITY][CONF_NAME],
                                 config[CONF_ADDRESS],
                                 config.get(CONF_UPDATE_INTERVAL))
    bme280 = Pvariable(config[CONF_ID], rhs)
    if CONF_OVERSAMPLING in config[CONF_TEMPERATURE]:
        constant = OVERSAMPLING_OPTIONS[config[CONF_TEMPERATURE]
                                        [CONF_OVERSAMPLING]]
        add(bme280.set_temperature_oversampling(constant))
    if CONF_OVERSAMPLING in config[CONF_PRESSURE]:
        constant = OVERSAMPLING_OPTIONS[config[CONF_PRESSURE]
                                        [CONF_OVERSAMPLING]]
        add(bme280.set_pressure_oversampling(constant))
    if CONF_OVERSAMPLING in config[CONF_HUMIDITY]:
        constant = OVERSAMPLING_OPTIONS[config[CONF_HUMIDITY]
                                        [CONF_OVERSAMPLING]]
        add(bme280.set_humidity_oversampling(constant))
    if CONF_IIR_FILTER in config:
        constant = IIR_FILTER_OPTIONS[config[CONF_IIR_FILTER]]
        add(bme280.set_iir_filter(constant))

    sensor.setup_sensor(bme280.Pget_temperature_sensor(),
                        config[CONF_TEMPERATURE])
    sensor.setup_sensor(bme280.Pget_pressure_sensor(), config[CONF_PRESSURE])
    sensor.setup_sensor(bme280.Pget_humidity_sensor(), config[CONF_HUMIDITY])
    setup_component(bme280, config)
示例#2
0
def to_code(config):
    rhs = App.make_bmp085_sensor(config[CONF_TEMPERATURE][CONF_NAME],
                                 config[CONF_PRESSURE][CONF_NAME],
                                 config.get(CONF_UPDATE_INTERVAL))
    bmp = Pvariable(config[CONF_ID], rhs)
    if CONF_ADDRESS in config:
        add(bmp.set_address(HexIntLiteral(config[CONF_ADDRESS])))

    sensor.setup_sensor(bmp.Pget_temperature_sensor(),
                        config[CONF_TEMPERATURE])
    sensor.setup_sensor(bmp.Pget_pressure_sensor(), config[CONF_PRESSURE])
    setup_component(bmp, config)
示例#3
0
def to_code(config):
    rhs = App.make_ms5611_sensor(config[CONF_TEMPERATURE][CONF_NAME],
                                 config[CONF_PRESSURE][CONF_NAME],
                                 config.get(CONF_UPDATE_INTERVAL))
    ms5611 = Pvariable(config[CONF_ID], rhs)

    if CONF_ADDRESS in config:
        add(ms5611.set_address(config[CONF_ADDRESS]))

    sensor.setup_sensor(ms5611.Pget_temperature_sensor(),
                        config[CONF_TEMPERATURE])
    sensor.setup_sensor(ms5611.Pget_pressure_sensor(), config[CONF_PRESSURE])
    setup_component(ms5611, config)