diff --git a/bin/weeutil/weeutil.py b/bin/weeutil/weeutil.py index a89696c6..4051c767 100644 --- a/bin/weeutil/weeutil.py +++ b/bin/weeutil/weeutil.py @@ -1279,9 +1279,9 @@ def tobool(x): """ try: - if x.lower() in ['true', 'yes', 'y']: + if x.lower() in ('true', 'yes', 'y'): return True - elif x.lower() in ['false', 'no', 'n']: + elif x.lower() in ('false', 'no', 'n'): return False except AttributeError: pass diff --git a/bin/weewx/engine.py b/bin/weewx/engine.py index 7fe9708b..e61c8677 100644 --- a/bin/weewx/engine.py +++ b/bin/weewx/engine.py @@ -460,8 +460,10 @@ class StdQC(StdService): except KeyError: log.info("No QC information in config file.") return + log_failure = to_bool(weeutil.config.search_up(config_dict['StdQC'], + 'log_failure', True)) - self.qc = weewx.qc.QC(mm_dict) + self.qc = weewx.qc.QC(mm_dict, log_failure) self.bind(weewx.NEW_LOOP_PACKET, self.new_loop_packet) self.bind(weewx.NEW_ARCHIVE_RECORD, self.new_archive_record) diff --git a/bin/weewx/qc.py b/bin/weewx/qc.py index 2923b2bb..cd87cf20 100644 --- a/bin/weewx/qc.py +++ b/bin/weewx/qc.py @@ -24,7 +24,7 @@ log = logging.getLogger(__name__) class QC(object): """Class to apply quality checks to a record.""" - def __init__(self, mm_dict): + def __init__(self, mm_dict, log_failure=True): """ Initialize Args: @@ -34,6 +34,8 @@ class QC(object): (min, max, unit), where min and max are as before, but the value 'unit' is the unit the min and max values are in. If 'unit' is not specified, then the values must be in the same unit as the incoming record (a risky supposition!). + + log_failure: True to log values outside of their limits. False otherwise. """ self.mm_dict = {} @@ -44,6 +46,8 @@ class QC(object): self.mm_dict[obs_type][0] = to_float(self.mm_dict[obs_type][0]) self.mm_dict[obs_type][1] = to_float(self.mm_dict[obs_type][1]) + self.log_failure = log_failure + def apply_qc(self, data_dict, data_type=''): """Apply quality checks to the data in a record""" @@ -62,7 +66,8 @@ class QC(object): max_v = converter.convert((max_v, min_max_unit, group))[0] if not min_v <= data_dict[obs_type] <= max_v: - log.warning("%s %s value '%s' %s outside limits (%s, %s)", - weeutil.weeutil.timestamp_to_string(data_dict['dateTime']), - data_type, obs_type, data_dict[obs_type], min_v, max_v) + if self.log_failure: + log.warning("%s %s value '%s' %s outside limits (%s, %s)", + weeutil.weeutil.timestamp_to_string(data_dict['dateTime']), + data_type, obs_type, data_dict[obs_type], min_v, max_v) data_dict[obs_type] = None diff --git a/docs/changes.txt b/docs/changes.txt index 44397994..d91dad36 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -144,8 +144,8 @@ Updated the version of six.py included with WeeWX to 1.15.0. Fixes issue #657. Option aggregate_interval can now be specified by using one of the "shortcuts", that is, 'hour', 'day', 'week', 'month', or 'year'. -Options "log_success" and "log_failure" are now honored by the StdArchive -service. +Options "log_success" and "log_failure" are now honored by the StdArchive and +StdQC services. Fixes issues #727. 4.4.0 01/30/2021