Skip to content

Commit

Permalink
Unit conversion bug fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
brewster76 committed Dec 27, 2014
1 parent 3a10203 commit 84191df
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions bin/user/gaugeengine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 84191df

Please sign in to comment.