From e526bde0caabc979f4b80ab394193e7bf494aad3 Mon Sep 17 00:00:00 2001 From: Wilfred Tyler Gee Date: Sun, 3 Sep 2023 10:46:48 -1000 Subject: [PATCH] Make the `get_errors` call optional and `False` by default (I've never seen an error). --- src/aag/weather.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/aag/weather.py b/src/aag/weather.py index 46188f9..e1f1a84 100644 --- a/src/aag/weather.py +++ b/src/aag/weather.py @@ -117,12 +117,13 @@ def capture(self, callback: Callable | None = None, units: WhichUnits = 'none') except KeyboardInterrupt: pass - def get_reading(self, units: WhichUnits = 'none', avg_times: int = 3) -> dict: + def get_reading(self, units: WhichUnits = 'none', get_errors: bool = False, avg_times: int = 3) -> dict: """ Get a single reading of all values. Args: units: The astropy units to return the reading in, default 'none', can be 'metric' or 'imperial'. + get_errors: Whether to get the internal errors, default False. avg_times: The number of times to average the readings, default 5. Returns: @@ -139,9 +140,11 @@ def avg_times(fn, n=avg_times): 'wind_speed': avg_times(self.get_wind_speed), 'rain_frequency': avg_times(self.get_rain_frequency), 'pwm': self.get_pwm(), - **{f'error_{i:02d}': err for i, err in enumerate(self.get_errors())} } + if get_errors: + reading.update(**{f'error_{i:02d}': err for i, err in enumerate(self.get_errors())}) + # Add the safety values. reading = self.get_safe_reading(reading)