Example #1
0
def to_code(config):
    rhs = App.make_wifi_signal_sensor(config[CONF_NAME], config.get(CONF_UPDATE_INTERVAL))
    make = variable(config[CONF_MAKE_ID], rhs)
    wifi = make.Pwifi

    sensor.setup_sensor(wifi, make.Pmqtt, config)
    setup_component(wifi, config)
Example #2
0
def to_code(config):
    rhs = App.make_uptime_sensor(config[CONF_NAME], config.get(CONF_UPDATE_INTERVAL))
    make = variable(config[CONF_MAKE_ID], rhs)
    uptime = make.Puptime

    sensor.setup_sensor(uptime, make.Pmqtt, config)
    setup_component(uptime, config)
Example #3
0
def to_code(config):
    pin = None
    for pin in gpio_input_pin_expression(config[CONF_PIN]):
        yield
    rhs = App.make_duty_cycle_sensor(config[CONF_NAME], pin,
                                     config.get(CONF_UPDATE_INTERVAL))
    make = variable(config[CONF_MAKE_ID], rhs)
    sensor.setup_sensor(make.Pduty, make.Pmqtt, config)
Example #4
0
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)
Example #5
0
def to_code(config):
    rhs = App.make_adc_sensor(config[CONF_NAME], config[CONF_PIN],
                              config.get(CONF_UPDATE_INTERVAL))
    make = variable(MakeADCSensor, config[CONF_MAKE_ID], rhs)
    adc = make.Padc
    if CONF_ATTENUATION in config:
        add(adc.set_attenuation(ATTENUATION_MODES[config[CONF_ATTENUATION]]))
    sensor.setup_sensor(make.Padc, make.Pmqtt, config)
Example #6
0
def to_code(config):
    rhs = App.make_bh1750_sensor(config[CONF_NAME], config[CONF_ADDRESS],
                                 config.get(CONF_UPDATE_INTERVAL))
    make_bh1750 = variable(config[CONF_MAKE_ID], rhs)
    bh1750 = make_bh1750.Pbh1750
    if CONF_RESOLUTION in config:
        add(bh1750.set_resolution(BH1750_RESOLUTIONS[config[CONF_RESOLUTION]]))
    sensor.setup_sensor(bh1750, make_bh1750.Pmqtt, config)
Example #7
0
def to_code(config):
    rhs = App.make_mqtt_subscribe_sensor(config[CONF_NAME], config[CONF_TOPIC])
    make = variable(config[CONF_MAKE_ID], rhs)

    if CONF_QOS in config:
        add(make.Psensor.set_qos(config[CONF_QOS]))

    sensor.setup_sensor(make.Psensor, make.Pmqtt, config)
Example #8
0
def to_code(config):
    rhs = App.make_htu21d_sensor(config[CONF_TEMPERATURE][CONF_NAME],
                                 config[CONF_HUMIDITY][CONF_NAME],
                                 config.get(CONF_UPDATE_INTERVAL))
    htu21d = variable(config[CONF_MAKE_ID], rhs)
    sensor.setup_sensor(htu21d.Phtu21d.Pget_temperature_sensor(), htu21d.Pmqtt_temperature,
                        config[CONF_TEMPERATURE])
    sensor.setup_sensor(htu21d.Phtu21d.Pget_humidity_sensor(), htu21d.Pmqtt_humidity,
                        config[CONF_HUMIDITY])
Example #9
0
def to_code(config):
    template_ = None
    for template_ in process_lambda(config[CONF_LAMBDA], [],
                                    return_type=optional.template(float_)):
        yield
    rhs = App.make_template_sensor(config[CONF_NAME], template_,
                                   config.get(CONF_UPDATE_INTERVAL))
    make = variable(config[CONF_MAKE_ID], rhs)
    sensor.setup_sensor(make.Ptemplate_, make.Pmqtt, config)
Example #10
0
def to_code(config):
    rhs = App.make_dht12_sensor(config[CONF_TEMPERATURE][CONF_NAME],
                                config[CONF_HUMIDITY][CONF_NAME],
                                config.get(CONF_UPDATE_INTERVAL))
    dht = variable(MakeDHT12Sensor, config[CONF_MAKE_ID], rhs)

    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])
Example #11
0
def to_code(config):
    rhs = App.make_adc_sensor(config[CONF_NAME], config[CONF_PIN],
                              config.get(CONF_UPDATE_INTERVAL))
    make = variable('Application::MakeADCSensor', config[CONF_ID], rhs)
    adc = make.Padc
    if CONF_ATTENUATION in config:
        attenuation = ATTENUATION_MODES[config[CONF_ATTENUATION]]
        add(adc.set_attenuation(RawExpression(attenuation)))
    sensor.setup_sensor(adc, config)
    sensor.setup_mqtt_sensor_component(make.Pmqtt, config)
Example #12
0
def to_code(config):
    rhs = App.make_hdc1080_sensor(config[CONF_TEMPERATURE][CONF_NAME],
                                  config[CONF_HUMIDITY][CONF_NAME],
                                  config.get(CONF_UPDATE_INTERVAL))
    hdc1080 = variable(MakeHDC1080Sensor, config[CONF_MAKE_ID], rhs)

    sensor.setup_sensor(hdc1080.Phdc1080.Pget_temperature_sensor(),
                        hdc1080.Pmqtt_temperature, config[CONF_TEMPERATURE])
    sensor.setup_sensor(hdc1080.Phdc1080.Pget_humidity_sensor(),
                        hdc1080.Pmqtt_humidity, config[CONF_HUMIDITY])
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)
Example #14
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)
Example #15
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)
Example #16
0
def to_code(config):
    pin = config[CONF_PIN]
    if pin == 'VCC':
        pin = 0
    rhs = App.make_adc_sensor(config[CONF_NAME], pin,
                              config.get(CONF_UPDATE_INTERVAL))
    make = variable(config[CONF_MAKE_ID], rhs)
    adc = make.Padc
    if CONF_ATTENUATION in config:
        add(adc.set_attenuation(ATTENUATION_MODES[config[CONF_ATTENUATION]]))
    sensor.setup_sensor(adc, make.Pmqtt, config)
    setup_component(adc, config)
Example #17
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 = variable(MakeBMP085Sensor, config[CONF_MAKE_ID], rhs)
    if CONF_ADDRESS in config:
        add(bmp.Pbmp.set_address(HexIntLiteral(config[CONF_ADDRESS])))

    sensor.setup_sensor(bmp.Pbmp.Pget_temperature_sensor(),
                        bmp.Pmqtt_temperature, config[CONF_TEMPERATURE])
    sensor.setup_sensor(bmp.Pbmp.Pget_pressure_sensor(), bmp.Pmqtt_pressure,
                        config[CONF_PRESSURE])
Example #18
0
def to_code(config):
    rhs = App.make_tsl2561_sensor(config[CONF_NAME], config[CONF_ADDRESS],
                                  config.get(CONF_UPDATE_INTERVAL))
    make_tsl = variable(config[CONF_MAKE_ID], rhs)
    tsl2561 = make_tsl.Ptsl2561
    if CONF_INTEGRATION_TIME in config:
        add(tsl2561.set_integration_time(INTEGRATION_TIMES[config[CONF_INTEGRATION_TIME]]))
    if CONF_GAIN in config:
        add(tsl2561.set_gain(GAINS[config[CONF_GAIN]]))
    if CONF_IS_CS_PACKAGE in config:
        add(tsl2561.set_is_cs_package(config[CONF_IS_CS_PACKAGE]))
    sensor.setup_sensor(tsl2561, make_tsl.Pmqtt, config)
Example #19
0
def to_code(config):
    rhs = App.make_htu21d_sensor(config[CONF_TEMPERATURE][CONF_NAME],
                                 config[CONF_HUMIDITY][CONF_NAME],
                                 config.get(CONF_UPDATE_INTERVAL))
    htu21d = variable('Application::MakeHTU21DSensor', config[CONF_ID], rhs)
    sensor.setup_sensor(htu21d.Phtu21d.Pget_temperature_sensor(),
                        config[CONF_TEMPERATURE])
    sensor.setup_mqtt_sensor_component(htu21d.Pmqtt_temperature,
                                       config[CONF_TEMPERATURE])
    sensor.setup_sensor(htu21d.Phtu21d.Pget_humidity_sensor(),
                        config[CONF_HUMIDITY])
    sensor.setup_mqtt_sensor_component(htu21d.Pmqtt_humidity,
                                       config[CONF_HUMIDITY])
Example #20
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))
    make = variable(config[CONF_MAKE_ID], rhs)

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

    sensor.setup_sensor(make.Pms5611.Pget_temperature_sensor(),
                        make.Pmqtt_temperature, config[CONF_TEMPERATURE])
    sensor.setup_sensor(make.Pms5611.Pget_pressure_sensor(),
                        make.Pmqtt_pressure, config[CONF_PRESSURE])
Example #21
0
def to_code(config):
    rhs = App.make_hdc1080_sensor(config[CONF_TEMPERATURE][CONF_NAME],
                                  config[CONF_HUMIDITY][CONF_NAME],
                                  config.get(CONF_UPDATE_INTERVAL))
    make = variable(config[CONF_MAKE_ID], rhs)
    hdc1080 = make.Phdc1080
    Pvariable(config[CONF_ID], hdc1080)

    sensor.setup_sensor(hdc1080.Pget_temperature_sensor(),
                        make.Pmqtt_temperature, config[CONF_TEMPERATURE])
    sensor.setup_sensor(hdc1080.Pget_humidity_sensor(), make.Pmqtt_humidity,
                        config[CONF_HUMIDITY])
    setup_component(hdc1080, config)
Example #22
0
def to_code(config):
    rhs = App.make_sht3xd_sensor(config[CONF_TEMPERATURE][CONF_NAME],
                                 config[CONF_HUMIDITY][CONF_NAME],
                                 config.get(CONF_UPDATE_INTERVAL))
    sht3xd = variable(MakeSHT3XDSensor, config[CONF_MAKE_ID], rhs)

    if CONF_ACCURACY in config:
        add(sht3xd.Psht3xd.set_accuracy(SHT_ACCURACIES[config[CONF_ACCURACY]]))

    sensor.setup_sensor(sht3xd.Psht3xd.Pget_temperature_sensor(),
                        sht3xd.Pmqtt_temperature, config[CONF_TEMPERATURE])
    sensor.setup_sensor(sht3xd.Psht3xd.Pget_humidity_sensor(),
                        sht3xd.Pmqtt_humidity, config[CONF_HUMIDITY])
Example #23
0
def to_code(config):
    rhs = App.make_dht12_sensor(config[CONF_TEMPERATURE][CONF_NAME],
                                config[CONF_HUMIDITY][CONF_NAME],
                                config.get(CONF_UPDATE_INTERVAL))
    make = variable(config[CONF_MAKE_ID], rhs)
    dht = make.Pdht12
    Pvariable(config[CONF_ID], dht)

    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)
Example #24
0
def to_code(config):
    pin_a = gpio_input_pin_expression(config[CONF_PIN_A])
    pin_b = gpio_input_pin_expression(config[CONF_PIN_B])
    rhs = App.make_rotary_encoder_sensor(config[CONF_NAME], pin_a, pin_b)
    make = variable(MakeRotaryEncoderSensor, config[CONF_MAKE_ID], rhs)
    encoder = make.Protary_encoder
    if CONF_PIN_RESET in config:
        pin_i = gpio_input_pin_expression(config[CONF_PIN_RESET])
        add(encoder.set_reset_pin(pin_i))
    if CONF_RESOLUTION in config:
        resolution = RESOLUTIONS[config[CONF_RESOLUTION]]
        add(encoder.set_resolution(resolution))
    sensor.setup_sensor(encoder, make.Pmqtt, config)
Example #25
0
def to_code(config):
    rhs = App.make_template_sensor(config[CONF_NAME],
                                   config.get(CONF_UPDATE_INTERVAL))
    make = variable(config[CONF_MAKE_ID], rhs)
    template = make.Ptemplate_

    sensor.setup_sensor(template, make.Pmqtt, config)
    setup_component(template, config)

    for template_ in process_lambda(config[CONF_LAMBDA], [],
                                    return_type=optional.template(float_)):
        yield
    add(template.set_template(template_))
Example #26
0
def to_code(config):
    trigger = exp_gpio_output_pin(config[CONF_TRIGGER_PIN])
    echo = exp_gpio_input_pin(config[CONF_ECHO_PIN])
    rhs = App.make_ultrasonic_sensor(config[CONF_NAME], trigger, echo,
                                     config.get(CONF_UPDATE_INTERVAL))
    make = variable('Application::MakeUltrasonicSensor', config[CONF_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, config)
    sensor.setup_mqtt_sensor_component(make.Pmqtt, config)
Example #27
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])
Example #28
0
def to_code(config):
    uart = None
    for uart in get_variable(config[CONF_UART_ID]):
        yield
    rhs = App.make_mhz19_sensor(uart, config[CONF_CO2][CONF_NAME],
                                config.get(CONF_UPDATE_INTERVAL))
    make = variable(config[CONF_MAKE_ID], rhs)
    mhz19 = make.Pmhz19
    sensor.setup_sensor(mhz19.Pget_co2_sensor(), make.Pmqtt, config[CONF_CO2])

    if CONF_TEMPERATURE in config:
        sensor.register_sensor(
            mhz19.Pmake_temperature_sensor(
                config[CONF_TEMPERATURE][CONF_NAME]), config[CONF_TEMPERATURE])
Example #29
0
def to_code(config):
    rhs = App.make_sht3xd_sensor(config[CONF_TEMPERATURE][CONF_NAME],
                                 config[CONF_HUMIDITY][CONF_NAME],
                                 config[CONF_ADDRESS],
                                 config.get(CONF_UPDATE_INTERVAL))
    make = variable(config[CONF_MAKE_ID], rhs)
    sht3xd = make.Psht3xd
    Pvariable(config[CONF_ID], sht3xd)

    sensor.setup_sensor(sht3xd.Pget_temperature_sensor(), make.Pmqtt_temperature,
                        config[CONF_TEMPERATURE])
    sensor.setup_sensor(sht3xd.Pget_humidity_sensor(), make.Pmqtt_humidity,
                        config[CONF_HUMIDITY])
    setup_component(sht3xd, config)
Example #30
0
def to_code(config):
    rhs = App.make_bme680_sensor(config[CONF_TEMPERATURE][CONF_NAME],
                                 config[CONF_PRESSURE][CONF_NAME],
                                 config[CONF_HUMIDITY][CONF_NAME],
                                 config[CONF_GAS_RESISTANCE][CONF_NAME],
                                 config[CONF_ADDRESS],
                                 config.get(CONF_UPDATE_INTERVAL))
    make = variable(MakeBME680Sensor, config[CONF_MAKE_ID], rhs)
    bme680 = make.Pbme680
    if CONF_OVERSAMPLING in config[CONF_TEMPERATURE]:
        constant = OVERSAMPLING_OPTIONS[config[CONF_TEMPERATURE]
                                        [CONF_OVERSAMPLING]]
        add(bme680.set_temperature_oversampling(constant))
    if CONF_OVERSAMPLING in config[CONF_PRESSURE]:
        constant = OVERSAMPLING_OPTIONS[config[CONF_PRESSURE]
                                        [CONF_OVERSAMPLING]]
        add(bme680.set_pressure_oversampling(constant))
    if CONF_OVERSAMPLING in config[CONF_HUMIDITY]:
        constant = OVERSAMPLING_OPTIONS[config[CONF_HUMIDITY]
                                        [CONF_OVERSAMPLING]]
        add(bme680.set_humidity_oversampling(constant))
    if CONF_IIR_FILTER in config:
        constant = IIR_FILTER_OPTIONS[config[CONF_IIR_FILTER]]
        add(bme680.set_iir_filter(constant))

    sensor.setup_sensor(bme680.Pget_temperature_sensor(),
                        make.Pmqtt_temperature, config[CONF_TEMPERATURE])
    sensor.setup_sensor(bme680.Pget_pressure_sensor(), make.Pmqtt_pressure,
                        config[CONF_PRESSURE])
    sensor.setup_sensor(bme680.Pget_humidity_sensor(), make.Pmqtt_humidity,
                        config[CONF_HUMIDITY])
    sensor.setup_sensor(bme680.Pget_gas_resistance_sensor(),
                        make.Pmqtt_gas_resistance, config[CONF_GAS_RESISTANCE])