Exemple #1
0
def to_code(config):
    for conf in config:
        address = HexIntLiteral(conf[CONF_ADDRESS])
        rhs = App.make_ads1115_component(address)
        ads1115 = Pvariable(ADS1115_COMPONENT_CLASS, conf[CONF_ID], rhs)
        if CONF_RATE in conf:
            add(ads1115.set_rate(RawExpression(RATES[conf[CONF_RATE]])))
Exemple #2
0
def to_code(config):
    for conf in config:
        rhs = App.make_pca9685_component(conf.get(CONF_FREQUENCY))
        pca9685 = Pvariable(PCA9685_COMPONENT_TYPE, conf[CONF_ID], rhs)
        if CONF_ADDRESS in conf:
            add(pca9685.set_address(HexIntLiteral(conf[CONF_ADDRESS])))
        if CONF_PHASE_BALANCER in conf:
            phase_balancer = RawExpression(u'PCA9685_PhaseBalancer_{}'.format(
                conf[CONF_PHASE_BALANCER]))
            add(pca9685.set_phase_balancer(phase_balancer))
Exemple #3
0
def to_code(config):
    for hub in get_variable(config[CONF_DALLAS_ID]):
        yield
    if CONF_ADDRESS in config:
        address = HexIntLiteral(config[CONF_ADDRESS])
        rhs = hub.Pget_sensor_by_address(config[CONF_NAME], address,
                                         config.get(CONF_RESOLUTION))
    else:
        rhs = hub.Pget_sensor_by_index(config[CONF_NAME], config[CONF_INDEX],
                                       config.get(CONF_RESOLUTION))
    sensor.register_sensor(rhs, config)
Exemple #4
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])
Exemple #5
0
def to_code(config):
    hub = get_variable(config.get(CONF_DALLAS_ID), DallasComponent)
    update_interval = config.get(CONF_UPDATE_INTERVAL)
    if CONF_RESOLUTION in config and update_interval is None:
        update_interval = 10000

    if CONF_ADDRESS in config:
        address = HexIntLiteral(config[CONF_ADDRESS])
        rhs = hub.Pget_sensor_by_address(config[CONF_NAME], address, update_interval,
                                         config.get(CONF_RESOLUTION))
    else:
        rhs = hub.Pget_sensor_by_index(config[CONF_NAME], config[CONF_INDEX],
                                       update_interval, config.get(CONF_RESOLUTION))
    sensor.register_sensor(rhs, config)
Exemple #6
0
def to_code(config):
    for conf in config:
        rhs = App.make_pca9685_component(conf.get(CONF_FREQUENCY))
        pca9685 = Pvariable(PCA9685OutputComponent, conf[CONF_ID], rhs)
        if CONF_ADDRESS in conf:
            add(pca9685.set_address(HexIntLiteral(conf[CONF_ADDRESS])))
Exemple #7
0
def safe_hex(value):
    if value is None:
        return None
    return HexIntLiteral(value)