stjohnjohnson / purple-air.py

Python script to help pull Purple-Air sensor data into Home Assistant
MIT License
5 stars 0 forks source link

Formula correction in averaging the two AQI sensor readings #6

Closed Docano closed 2 years ago

Docano commented 2 years ago

Very minor tweak. In the following snippet, I think the intention is to average the pm2.5 readings from each of the 2 sensors in the json file (since the purpleair sensors have 2 sensors onboard and averages them).

pm2a = float(data['results'][0]['PM2_5Value'])
pm2b = float(data['results'][0]['PM2_5Value'])
pm2 = (pm2a + pm2b) / 2

should be corrected to

pm2a = float(data['results'][0]['PM2_5Value'])
pm2b = float(data['results'][1]['PM2_5Value'])
pm2 = (pm2a + pm2b) / 2

The 2nd sensor is found at data['results'][0]

stjohnjohnson commented 2 years ago

Good catch! Let me fix that real quick.