diff --git a/bin/user/gaugeengine.py b/bin/user/gaugeengine.py index c1b00ff..d034829 100644 --- a/bin/user/gaugeengine.py +++ b/bin/user/gaugeengine.py @@ -126,15 +126,23 @@ def setup(self): self.gauge_dict = self.skin_dict['GaugeGenerator'] self.units_dict = self.skin_dict['Units'] + # Create a converter to get this into the desired units + self.converter = weewx.units.Converter(self.units_dict['Groups']) + # Lookup the last reading in the archive self.lastGoodStamp = self.db_manager.lastGoodStamp() - last_reading = self.db_manager.getRecord(self.db_manager.lastGoodStamp()) - # Create a converter to get this into the desired units - self.converter = weewx.units.Converter(self.units_dict['Groups']) + self.record_dict_vtd = None + batch_records = self.db_manager.genBatchRecords(self.lastGoodStamp - 1, self.lastGoodStamp) - self.record_dict_vtd = self.converter.convertDict(last_reading) - self.record_dict_vtd['usUnits'] = self.db_manager.std_unit_system + try: + for rec in batch_records: + print rec + if self.record_dict_vtd is None: + self.record_dict_vtd = rec + + except: + syslog.syslog(syslog.LOG_INFO, "GaugeGenerator: Cannot find the current reading") def gen_gauges(self): """Generate the gauges.""" @@ -232,7 +240,7 @@ def gen_gauge(self, gaugename, plot_options, img_file): # Convert it to units in skin.conf file value_now = weewx.units.convert(weewx.units.as_value_tuple(self.record_dict_vtd, columnname), target_unit)[0] - syslog.syslog(syslog.LOG_DEBUG, "GaugeGenerator: %s reading %s = %s" % (gaugename, columnname, value_now)) + syslog.syslog(syslog.LOG_INFO, "GaugeGenerator: %s reading %s = %s" % (gaugename, columnname, value_now)) dial_format = None