Skip to content

Commit

Permalink
Make the get_errors call optional and False by default (I've neve…
Browse files Browse the repository at this point in the history
…r seen an error).
  • Loading branch information
wtgee committed Sep 3, 2023
1 parent ca15890 commit e526bde
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/aag/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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)

Expand Down

0 comments on commit e526bde

Please sign in to comment.