Skip to content

Commit

Permalink
Fix AQI = 0 bug (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanthoss authored Nov 7, 2022
1 parent 84cea50 commit 899a70b
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ def upload_measurement():

aqi_value = None
if "SDS_P1" in data_points and "SDS_P2" in data_points:
aqi_value = float(
aqi_value = int(
aqi.to_aqi([(aqi.POLLUTANT_PM10, data_points["SDS_P1"]), (aqi.POLLUTANT_PM25, data_points["SDS_P2"])])
)
elif "PMS_P1" in data_points and "PMS_P2" in data_points:
aqi_value = float(
aqi_value = int(
aqi.to_aqi([(aqi.POLLUTANT_PM10, data_points["PMS_P1"]), (aqi.POLLUTANT_PM25, data_points["PMS_P2"])])
)
else:
app.logger.warn("Measurement for {node_tag} does not contain pollutant data.")

if aqi_value:
if aqi_value is not None:
data_points["AQI_value"] = aqi_value
data_points["AQI_category"] = get_aqi_category(aqi_value)

Expand Down

0 comments on commit 899a70b

Please sign in to comment.