Example #1
0
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)
Example #2
0
def to_code(config):
    rhs = App.make_tcs34725(config.get(CONF_UPDATE_INTERVAL))
    tcs = Pvariable(config[CONF_ID], rhs)
    if CONF_ADDRESS in config:
        add(tcs.set_address(config[CONF_ADDRESS]))
    if CONF_INTEGRATION_TIME in config:
        add(
            tcs.set_integration_time(
                TCS34725_INTEGRATION_TIMES[config[CONF_INTEGRATION_TIME]]))
    if CONF_GAIN in config:
        add(tcs.set_gain(TCS34725_GAINS[config[CONF_GAIN]]))
    if CONF_RED_CHANNEL in config:
        conf = config[CONF_RED_CHANNEL]
        sensor.register_sensor(tcs.Pmake_red_sensor(conf[CONF_NAME]), conf)
    if CONF_GREEN_CHANNEL in config:
        conf = config[CONF_GREEN_CHANNEL]
        sensor.register_sensor(tcs.Pmake_green_sensor(conf[CONF_NAME]), conf)
    if CONF_BLUE_CHANNEL in config:
        conf = config[CONF_BLUE_CHANNEL]
        sensor.register_sensor(tcs.Pmake_blue_sensor(conf[CONF_NAME]), conf)
    if CONF_CLEAR_CHANNEL in config:
        conf = config[CONF_CLEAR_CHANNEL]
        sensor.register_sensor(tcs.Pmake_clear_sensor(conf[CONF_NAME]), conf)
    if CONF_ILLUMINANCE in config:
        conf = config[CONF_ILLUMINANCE]
        sensor.register_sensor(tcs.Pmake_illuminance_sensor(conf[CONF_NAME]),
                               conf)
    if CONF_COLOR_TEMPERATURE in config:
        conf = config[CONF_COLOR_TEMPERATURE]
        sensor.register_sensor(
            tcs.Pmake_color_temperature_sensor(conf[CONF_NAME]), conf)

    setup_component(tcs, config)