Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # -*- coding: utf-8 -*-
- import datetime
- import calendar
- import time
- import os
- import subprocess
- def checkhumidity():
- p = subprocess.Popen(["/project/dht22/monitor/humidity.sh"], stdout=subprocess.PIPE)
- getstatus = p.communicate()[0].strip()
- return float(getstatus) + 0
- def checktemperature():
- p = subprocess.Popen(["/project/dht22/monitor/temperature.sh"], stdout=subprocess.PIPE)
- getstatus = p.communicate()[0].strip()
- return float(getstatus) + 0
- def onoffstatus():
- p = subprocess.Popen(["/project/dht22/monitor/status.sh"], stdout=subprocess.PIPE)
- onoffstatus = p.communicate()[0].strip()
- return int(float(onoffstatus)) + 0
- levelhumidity = 30
- def min():
- temp = 0
- #temp = checktemperature()
- humidity = checkhumidity()
- hnow = datetime.datetime.now().strftime('%H:%M:%S')
- if (levelhumidity > humidity):
- if (onoffstatus() == 1):
- os.system("/project/dht22/monitor/off.sh")
- time.sleep(5)
- #print(u"мин. Час:%s темп:%s - влажност:%s - вентилатор:%s ".encode('utf-8') %(hnow,temp,humidity,onoffstatus()))
- min()
- else:
- pass
- def max():
- temp = 0
- #temp = checktemperature()
- levelhumidity = 27
- humidity = checkhumidity()
- hnow = datetime.datetime.now().strftime('%H:%M:%S')
- if (levelhumidity < humidity):
- if (onoffstatus() < 1):
- os.system("/project/dht22/monitor/on.sh")
- time.sleep(60)
- #print(u"макс. Час:%s темп:%s - влажност:%s - вентилатор:%s ".encode('utf-8') %(hnow,temp,humidity,onoffstatus()))
- max()
- else:
- pass
- #print u"Старт".encode('utf-8')
- try:
- while True: # this will carry on until you hit CTRL+C
- temp = 0
- #temp = checktemperature()
- humidity = checkhumidity()
- hnow = datetime.datetime.now().strftime('%H:%M:%S')
- if (humidity > levelhumidity):
- #print(u"старт макс. Час:%s темп:%s - влажност:%s - вентилатор:%s ".encode('utf-8') %(hnow,temp,humidity,onoffstatus()))
- max()
- time.sleep(1)
- if (humidity < levelhumidity):
- #print(u"старт мин. Час:%s темп:%s - влажност:%s - вентилатор:%s ".encode('utf-8') %(hnow,temp,humidity,onoffstatus()))
- min()
- time.sleep(1)
- except KeyboardInterrupt:
- pass
- finally: # this block will run no matter how the try block exits..
- pass
Add Comment
Please, Sign In to add comment