use database_field = hardware_name for sensor mapping

master
Matthew Wall 8 years ago
parent 5fb97a31be
commit dc7fed55a9

@ -42,7 +42,7 @@ import weewx.units
import weewx.wxformulas import weewx.wxformulas
DRIVER_NAME = 'netatmo' DRIVER_NAME = 'netatmo'
DRIVER_VERSION = "0.5" DRIVER_VERSION = "0.6"
INHG_PER_MBAR = 0.0295299830714 INHG_PER_MBAR = 0.0295299830714
MPH_TO_KPH = 1.60934 MPH_TO_KPH = 1.60934
@ -118,34 +118,34 @@ class NetatmoDriver(weewx.drivers.AbstractDevice):
# apparently battery_vp is in older firmware, whereas battery_percent is # apparently battery_vp is in older firmware, whereas battery_percent is
# in newer firmware. # in newer firmware.
DEFAULT_SENSOR_MAP = { DEFAULT_SENSOR_MAP = {
'*.NAMain.AbsolutePressure': 'pressure', 'pressure': '*.NAMain.AbsolutePressure',
'*.NAMain.Temperature': 'inTemp', 'inTemp': '*.NAMain.Temperature',
'*.NAMain.Humidity': 'inHumidity', 'inHumidity': '*.NAMain.Humidity',
'*.NAMain.CO2': 'co2', 'co2': '*.NAMain.CO2',
'*.NAMain.Noise': 'noise', 'noise': '*.NAMain.Noise',
'*.NAMain.wifi_status': 'wifi_status', 'wifi_status': '*.NAMain.wifi_status',
'*.NAModule1.Temperature': 'outTemp', 'outTemp': '*.NAModule1.Temperature',
'*.NAModule1.Humidity': 'outHumidity', 'outHumidity': '*.NAModule1.Humidity',
'*.NAModule1.rf_status': 'out_rf_status', 'out_rf_status': '*.NAModule1.rf_status',
'*.NAModule1.battery_vp': 'out_battery_vp', 'out_battery_vp': '*.NAModule1.battery_vp',
'*.NAModule1.battery_percent': 'outTempBatteryStatus', 'outTempBatteryStatus': '*.NAModule1.battery_percent',
'*.NAModule4.Temperature': 'extraTemp1', 'extraTemp1': '*.NAModule4.Temperature',
'*.NAModule4.Humidity': 'extraHumid1', 'extraHumid1': '*.NAModule4.Humidity',
'*.NAModule4.rf_status': 'extra_rf_status_1', 'extra_rf_status_1': '*.NAModule4.rf_status',
'*.NAModule4.battery_vp': 'extra_battery_vp_1', 'extra_battery_vp_1': '*.NAModule4.battery_vp',
'*.NAModule4.battery_percent': 'extra1BatteryStatus', 'extra1BatteryStatus': '*.NAModule4.battery_percent',
'*.NAModule2.WindStrength': 'windSpeed', 'windSpeed': '*.NAModule2.WindStrength',
'*.NAModule2.WindAngle': 'windDir', 'windDir': '*.NAModule2.WindAngle',
'*.NAModule2.GustStrength': 'windGust', 'windGust': '*.NAModule2.GustStrength',
'*.NAModule2.GustAngle': 'windGustDir', 'windGustDir': '*.NAModule2.GustAngle',
'*.NAModule2.rf_status': 'wind_rf_status', 'wind_rf_status': '*.NAModule2.rf_status',
'*.NAModule2.battery_vp': 'wind_battery_vp', 'wind_battery_vp': '*.NAModule2.battery_vp',
'*.NAModule2.battery_percent': 'windBatteryStatus', 'windBatteryStatus': '*.NAModule2.battery_percent',
'*.NAModule3.Rain': 'rain', 'rain': '*.NAModule3.Rain',
'*.NAModule3.sum_rain_24': 'rain_total', 'rain_total': '*.NAModule3.sum_rain_24',
'*.NAModule3.rf_status': 'rain_rf_status', 'rain_rf_status': '*.NAModule3.rf_status',
'*.NAModule3.battery_vp': 'rain_battery_vp', 'rain_battery_vp': '*.NAModule3.battery_vp',
'*.NAModule3.battery_percent': 'rainBatteryStatus'} 'rainBatteryStatus': '*.NAModule3.battery_percent'}
def __init__(self, **stn_dict): def __init__(self, **stn_dict):
loginf("driver version is %s" % DRIVER_VERSION) loginf("driver version is %s" % DRIVER_VERSION)
@ -200,9 +200,9 @@ class NetatmoDriver(weewx.drivers.AbstractDevice):
packet['dateTime'] = int(time.time() + 0.5) packet['dateTime'] = int(time.time() + 0.5)
packet['usUnits'] = weewx.METRIC packet['usUnits'] = weewx.METRIC
for n in self.sensor_map: for n in self.sensor_map:
label = self._find_match(n, data.keys()) label = self._find_match(self.sensor_map[n], data.keys())
if label: if label:
packet[self.sensor_map[n]] = data[label] packet[n] = data[label]
return packet return packet
@staticmethod @staticmethod

@ -1,3 +1,6 @@
0.6 31oct2016
* use database_name = hardware_name pattern for sensor mapping
0.4 06aug2016 0.4 06aug2016
* incorporate changes from scott grey * incorporate changes from scott grey
* default poll interval is now 300 instead of 600 * default poll interval is now 300 instead of 600

@ -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.4", version="0.6",
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