From 13d8d2da18e633fc70d6fbcfbe4b71a40457bf24 Mon Sep 17 00:00:00 2001 From: Matthew Wall Date: Sat, 23 Nov 2013 15:37:28 +0000 Subject: [PATCH] fixed wind speed multiplier in te923. provide mechanism for testing driver without weewx overhead. --- bin/weewx/drivers/te923.py | 33 ++++++++++++++++++++++++++------- bin/weewx/drivers/ws23xx.py | 23 ++++++++++++++++++----- setup.cfg | 2 +- 3 files changed, 45 insertions(+), 13 deletions(-) diff --git a/bin/weewx/drivers/te923.py b/bin/weewx/drivers/te923.py index b0e8786d..fda8fe4b 100644 --- a/bin/weewx/drivers/te923.py +++ b/bin/weewx/drivers/te923.py @@ -23,12 +23,16 @@ These stations were made by Hideki and branded as Honeywell, Meade, IROX Pro X, Mebus TE923, and TFA Nexus. -A single bucket tip is between 0.02 and 0.03 in (0.508 to 0.762 mm). +A single bucket tip is between 0.02 and 0.03 in (0.508 to 0.762 mm). This +driver assumes 0.025 in (0.635 mm). The station has altitude, latitude, longitude, and time. Read these during initialization and indicate any difference with values from weewx.conf. If conflicts, use the values from weewx.conf. +The station appears to average the wind speed rather than returning +instantaneous values. + Notes from Other Implementations It is not clear whether te923tool copied from wview or vice versa. te923tool @@ -68,6 +72,7 @@ claimInterface. # FIXME: add option to calculate windchill instead of using station value # FIXME: verify pressure/altimeter +# FIXME: verify default rain multiplier from __future__ import with_statement import optparse @@ -79,9 +84,9 @@ import weeutil import weewx.abstractstation import weewx.wxformulas -DRIVER_VERSION = '0.1' -DEBUG_READ = 1 -DEBUG_DECODE = 1 +DRIVER_VERSION = '0.2' +DEBUG_READ = 0 +DEBUG_DECODE = 0 def logmsg(dst, msg): syslog.syslog(dst, 'te923: %s' % msg) @@ -278,7 +283,20 @@ class TE923(weewx.abstractstation.AbstractStation): def data_to_packet(self, data, altitude=0, pressure_offset=None, last_rain=None, last_rain_ts=None): - """convert raw data to format and units required by weewx""" + """convert raw data to format and units required by weewx + + station weewx (metric) + temperature degree C degree C + humidity percent percent + uv index unitless unitless + pressure mbar mbar + wind speed mile/h km/h + wind gust mile/h km/h + wind dir degree degree + rain mm cm + rain rate cm/h + """ + packet = {} packet['usUnits'] = weewx.METRIC packet['dateTime'] = int(time.time() + 0.5) @@ -291,10 +309,10 @@ class TE923(weewx.abstractstation.AbstractStation): packet['UV'] = data['uv'] packet['windSpeed'] = data['windspeed'] if packet['windSpeed'] is not None: - packet['windSpeed'] *= 3.6 # weewx wants km/h + packet['windSpeed'] *= 1.60934 # speed is mph; weewx wants km/h packet['windGust'] = data['windgust'] if packet['windGust'] is not None: - packet['windGust'] *= 3.6 # weewx wants km/h + packet['windGust'] *= 1.60934 # speed is mph; weewx wants km/h if packet['windSpeed'] is not None and packet['windSpeed'] > 0: packet['windDir'] = data['winddir'] @@ -836,6 +854,7 @@ def main(): else: syslog.setlogmask(syslog.LOG_UPTO(syslog.LOG_INFO)) + print "te923 driver version %s" % DRIVER_VERSION station = None try: station = Station() diff --git a/bin/weewx/drivers/ws23xx.py b/bin/weewx/drivers/ws23xx.py index 634fadd2..8bcd6b50 100644 --- a/bin/weewx/drivers/ws23xx.py +++ b/bin/weewx/drivers/ws23xx.py @@ -85,7 +85,7 @@ import weeutil import weewx.abstractstation import weewx.wxformulas -DRIVER_VERSION = '0.1' +DRIVER_VERSION = '0.2' DEFAULT_PORT = '/dev/ttyUSB0' @@ -256,7 +256,19 @@ class WS23xx(weewx.abstractstation.AbstractStation): @staticmethod def data_to_packet(data, altitude=0, pressure_offset=None, last_rain=None): - """convert raw data to format and units required by weewx""" + """convert raw data to format and units required by weewx + + station weewx (metric) + temperature degree C degree C + humidity percent percent + uv index unitless unitless + pressure mbar mbar + wind speed m/s km/h + wind gust m/s km/h + wind dir degree degree + rain mm cm + rain rate cm/h + """ packet = {} packet['usUnits'] = weewx.METRIC @@ -283,13 +295,13 @@ class WS23xx(weewx.abstractstation.AbstractStation): else: packet['windGustDir'] = None - packet['rainRate'] = data['rh'] - if packet['rainRate'] is not None: - packet['rainRate'] /= 10 # weewx wants cm/hr packet['rainTotal'] = data['rt'] if packet['rainTotal'] is not None: packet['rainTotal'] /= 10 # weewx wants cm packet['rain'] = calculate_rain(packet['rainTotal'], last_rain) + packet['rainRate'] = data['rh'] + if packet['rainRate'] is not None: + packet['rainRate'] /= 10 # weewx wants cm/hr packet['heatindex'] = weewx.wxformulas.heatindexC( packet['outTemp'], packet['outHumidity']) @@ -1552,6 +1564,7 @@ def main(): if options.port: port = options.port + print "ws23xx driver version %s" % DRIVER_VERSION serial_port = LinuxSerialPort(port) try: data = WS23xx.get_raw_data(serial_port) diff --git a/setup.cfg b/setup.cfg index dfa4d79d..69fd9d7f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ [install] # Set the following to the root directory where weewx should be installed -home = /home/weewx +home = /opt/weewx-te923 # Given the value of 'home' above, the following are reasonable values