-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage_air_quality.py
34 lines (28 loc) · 1.26 KB
/
manage_air_quality.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import argparse
import purple_air_sensor as aqisensor
import ecobee_thermostat as thermo_stat
# In case of Nest, use this line instead:
# import nest_thermostat as thermo_stat
import datetime
import pytz
def manage_air_quality(aqi_sensor, thermostat, aqi_ceiling, fan_runtime_mins):
aqi = aqi_sensor.get_aqi()
if(aqi >= aqi_ceiling):
print(f'Current AQI of {str(aqi)} is bad! It is above the maximum acceptable AQI of {str(aqi_ceiling)}...running fan for {str(fan_runtime_mins)} min')
thermostat.set_fan_timer(fan_runtime_mins)
else:
print(f'Current AQI of {str(aqi)} is good! It is below the maximum acceptable AQI of {str(aqi_ceiling)}')
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--a', type=int, required=True)
parser.add_argument('--f', type=int, required=True)
args = parser.parse_args()
aqi_ceiling = args.a
fan_runtime_mins = args.f
aqi_sensor = aqisensor.sensor()
thermostat = thermo_stat.thermostat()
manage_air_quality(aqi_sensor, thermostat, aqi_ceiling, fan_runtime_mins)
if __name__ == '__main__':
main()
# Run with: python manage_air_quality.py --a [acceptable aqi threshold] --f [fan duration in minutes]
# example: python manage_air_quality_2.py --a 50 --f 15