Skip to content

Commit

Permalink
Act on results dict, not immutable data dict
Browse files Browse the repository at this point in the history
  • Loading branch information
djjudas21 committed Jan 9, 2024
1 parent 15b4958 commit 4432ec6
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions ecowitt_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,13 +152,6 @@ def logecowitt():
# Retrieve the POST body
data = request.form

# Check PM25 data from the WH41 sensor
# If the battery is low it gives junk readings
# https://github.com/djjudas21/ecowitt-exporter/issues/17
if data.get('pm25batt1') == '1' and data.get('pm25_ch1') == '1000':
# Drop erroneous reading
del data['pm25_ch1']

# Set up a dict to receive the processed results
results = {}

Expand Down Expand Up @@ -266,6 +259,16 @@ def logecowitt():
elif aqi_standard == 'nepm':
results['aqi'] = aqi_nepm(data['pm25_avg_24h_ch1'])

# Check data from the WH41 PM2.5 sensor
# If the battery is low it gives junk readings
# https://github.com/djjudas21/ecowitt-exporter/issues/17
if data.get('pm25batt1') == '1' and data.get('pm25_ch1') == '1000':
# Drop erroneous readings
app.logger.debug("Drop erroneous PM25 reading 'pm25_ch1': %s", results['pm25_ch1'])
del results['pm25_ch1']
del results['pm25_avg_24h_ch1']
del results['aqi']

# Now loop on our processed results and do things with them
points = []
for key, value in results.items():
Expand Down

0 comments on commit 4432ec6

Please sign in to comment.