From 899a70b6d7f54d6fb52e3291bd913b585b52886e Mon Sep 17 00:00:00 2001 From: Stefan Thoss Date: Mon, 7 Nov 2022 08:49:25 -0800 Subject: [PATCH] Fix AQI = 0 bug (#16) --- main.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/main.py b/main.py index eb763ce..574928a 100644 --- a/main.py +++ b/main.py @@ -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)