fixed rain conversion

master
Matthew Wall 8 years ago
parent 51a0bbd47a
commit c215b577d2

@ -42,7 +42,7 @@ import weewx.units
import weewx.wxformulas import weewx.wxformulas
DRIVER_NAME = 'netatmo' DRIVER_NAME = 'netatmo'
DRIVER_VERSION = "0.9" DRIVER_VERSION = "0.10"
INHG_PER_MBAR = 0.0295299830714 INHG_PER_MBAR = 0.0295299830714
MPH_TO_KPH = 1.60934 MPH_TO_KPH = 1.60934
@ -155,7 +155,6 @@ class NetatmoDriver(weewx.drivers.AbstractDevice):
loginf('sensor map is %s' % self.sensor_map) loginf('sensor map is %s' % self.sensor_map)
device_id = stn_dict.get('device_id', None) device_id = stn_dict.get('device_id', None)
mode = stn_dict.get('mode', 'cloud') mode = stn_dict.get('mode', 'cloud')
self.last_rain = None
if mode.lower() == 'sniff': if mode.lower() == 'sniff':
port = int(stn_dict.get('port', NetatmoDriver.DEFAULT_PORT)) port = int(stn_dict.get('port', NetatmoDriver.DEFAULT_PORT))
addr = stn_dict.get('host', NetatmoDriver.DEFAULT_HOST) addr = stn_dict.get('host', NetatmoDriver.DEFAULT_HOST)
@ -229,17 +228,6 @@ class NetatmoDriver(weewx.drivers.AbstractDevice):
return True return True
return False return False
def _augment_packet(self, packet):
if 'rain_total' in packet:
total = packet['rain_total']
if (total is not None and self.last_rain is not None and
total < self.last_rain):
loginf("rain counter decrement ignored:"
" new: %s old: %s" % (total, self.last_rain))
packet['rain'] = weewx.wxformulas.calculate_rain(
total, self.last_rain)
self.last_rain = total
class Collector(object): class Collector(object):
queue = Queue.Queue() queue = Queue.Queue()
@ -284,12 +272,14 @@ class CloudClient(Collector):
# mapping between observation name and function used to convert it # mapping between observation name and function used to convert it
CONVERSIONS = { CONVERSIONS = {
'Temperature': '_cvt_temperature', # 'Temperature': '_cvt_temperature',
'AbsolutePressure': '_cvt_pressure', # 'AbsolutePressure': '_cvt_pressure',
'Pressure': '_cvt_pressure', # 'Pressure': '_cvt_pressure',
'WindStrength': '_cvt_speed', # 'WindStrength': '_cvt_speed',
'GustStrength': '_cvt_speed', # 'GustStrength': '_cvt_speed',
'Rain': '_cvt_rain'} 'Rain': '_cvt_rain',
'sum_rain_24': '_cvt_rain',
'sum_rain_1': '_cvt_rain'}
# list of source units we need to watch for # list of source units we need to watch for
UNITS = ['unit', 'windunit', 'pressureunit'] UNITS = ['unit', 'windunit', 'pressureunit']
@ -374,15 +364,14 @@ class CloudClient(Collector):
if n in x['dashboard_data']: if n in x['dashboard_data']:
data[n] = x['dashboard_data'][n] data[n] = x['dashboard_data'][n]
# do any unit conversions - everything converts to weewx.METRIC # do any unit conversions - everything converts to weewx.METRIC
# it looks like all the data are METRIC even when netatmo units say otherwise for n in data:
# for n in data: if n in CloudClient.CONVERSIONS:
# try: try:
# func = CloudClient.CONVERSIONS.get(n) func = CloudClient.CONVERSIONS.get(n)
# if func: data[n] = getattr(CloudClient, func)(data[n], units_dict)
# data[n] = getattr(CloudClient, func)(data[n], units_dict) except ValueError, e:
# except ValueError, e: logerr("unit conversion failed for %s: %s" % (data[n], e))
# logerr("unit conversion failed for %s: %s" % (data[n], e)) data[n] = None
# data[n] = None
return data return data
@staticmethod @staticmethod

@ -1,3 +1,6 @@
0.10 30mar2017
* fix rain conversions
0.9 28mar2017 0.9 28mar2017
* fixed urf-8 typo * fixed urf-8 typo

@ -10,7 +10,7 @@ def loader():
class NetatmoInstaller(ExtensionInstaller): class NetatmoInstaller(ExtensionInstaller):
def __init__(self): def __init__(self):
super(NetatmoInstaller, self).__init__( super(NetatmoInstaller, self).__init__(
version="0.9", version="0.10",
name='netatmo', name='netatmo',
description='Driver for netatmo weather stations.', description='Driver for netatmo weather stations.',
author="Matthew Wall", author="Matthew Wall",

Loading…
Cancel
Save