From 4d803c012bd5ab32801b14d05cabebe101a0fdb1 Mon Sep 17 00:00:00 2001 From: Tom Keffer Date: Tue, 9 Mar 2021 06:09:50 -0800 Subject: [PATCH] Do not require a [StdConvert] section --- bin/weewx/engine.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/weewx/engine.py b/bin/weewx/engine.py index 915c3197..a43ee023 100644 --- a/bin/weewx/engine.py +++ b/bin/weewx/engine.py @@ -336,8 +336,13 @@ class StdConvert(StdService): # Initialize my base class: super(StdConvert, self).__init__(engine, config_dict) - # Get the target unit nickname (something like 'US' or 'METRIC'): - target_unit_nickname = config_dict['StdConvert']['target_unit'] + # Get the target unit nickname (something like 'US' or 'METRIC'). If there is no + # target, then do nothing + try: + target_unit_nickname = config_dict['StdConvert']['target_unit'] + except KeyError: + # Missing target unit. + return # Get the target unit: weewx.US, weewx.METRIC, weewx.METRICWX self.target_unit = weewx.units.unit_constants[target_unit_nickname.upper()] # Bind self.converter to the appropriate standard converter