Ejemplo n.º 1
0
def parse_config(filename):
    """
    Fnord
    """
    # {{{
    filename = expanduser(expandvars(filename))
    LOG.debug("Parsing configuration in file '%s'",filename)
    CONFIG.read(filename)
Ejemplo n.º 2
0
    def initialize(self, addr=""):
        config = CONFIG()

        if os.path.isfile(config.SETTPATH) or self.migrate:
            config.read()
            config.extend(addr, self.debug)
            config.generate()
        else:
            pull.halt("Migrations aren't applied. Apply them first!", True,
                      pull.RED)
Ejemplo n.º 3
0
def main():
    CONFIG.read()

    setup_network_and_time()

    dht_sensor = sensors.Dht(CONFIG.sensor_dht_pin, CONFIG.sensor_dht_type,
                             CONFIG.dht_temp_calibration,
                             CONFIG.dht_humid_calibration)

    ds18b20_sensor = sensors.Ds18x20(CONFIG.sensor_ds18x20_pin,
                                     CONFIG.ds18b20_temp_calibration)

    while True:
        fields = {
            'temperature1': dht_sensor.temperature(),
            'temperature2': ds18b20_sensor.temperature(),
            'humidity': dht_sensor.humidity(),
            'comment': '-',
            'time': time.time() + UNIX_EPOCH_DELTA,
            'location': CONFIG.location,
            'wifi_signal': get_wifi_signal(),
            'supply_voltage':
            0  # TODO   https://forum.micropython.org/viewtopic.php?t=533
        }
        log("Record:", fields)

        fields_translated = translate_field_names(fields, CONFIG.api_name)
        send_data(fields_translated)

        if CONFIG.sleep_between_measurements:
            if machine.reset_cause() != machine.DEEPSLEEP_RESET:
                # allows easier reflashing if done in 30s after powerup
                log("Wait 10s...")
                time.sleep(10)

            # in this case while loop is useless, because after wake up it will
            # start from begin
            good_night()
        else:
            time.sleep(CONFIG.update_period)