def controlHVAC(desiredTemp,hwTemp,fanMode='O'): global coolingHwStatus global heatingHwStatus global fanHwStatus global offHwStatus #print('coolingHwStatus: ', coolingHwStatus) #print('heatingHwStatus: ', heatingHwStatus) #print('fanHwStatus: ', fanHwStatus) #print('offHwStatus: ', offHwStatus) try: if fanMode =='H': #heating fanHwStatus = 'Off' offHwStatus = 'Off' #turn off the other pins incase they were already on GPIO.output(cool_pin ,0) GPIO.output(fan_pin ,0) #compare the temp and either keep running or turn off if desiredTemp > hwTemp: if heatingHwStatus != 'On': ThermoData.updateHwEvent('Heating Started') #print('Heating Started Event') #ThermoData.updateHwEvent('Heating Started') GPIO.output(heat_pin ,1) heatingHwStatus = 'On' if desiredTemp + 1 < hwTemp: if heatingHwStatus != 'Off': ThermoData.updateHwEvent('Heating Stopped') #print('Heating stopped Event') heatingHwStatus = 'Off' GPIO.output(heat_pin ,0) if fanMode =='C': #cooling fanHwStatus = 'Off' offHwStatus = 'Off' #turn off the other pins incase they were already on GPIO.output(heat_pin ,0) GPIO.output(fan_pin ,0) #compare the temp and either keep running or turn off if desiredTemp < hwTemp: if coolingHwStatus != 'On': ThermoData.updateHwEvent('Cooling Started') #print('Cooling Started Event') GPIO.output(cool_pin ,1) coolingHwStatus = 'On' if desiredTemp - 1 > hwTemp: if coolingHwStatus != 'Off': #print 'Cooling Off' ThermoData.updateHwEvent('Cooling Stopped') coolingHwStatus = 'Off' #print('Cooling Stopped Event') GPIO.output(cool_pin ,0) if fanMode =='F': #Fan offHwStatus = 'Off' #turn off the other pins incase they were already on GPIO.output(cool_pin ,0) GPIO.output(fan_pin ,0) if fanHwStatus != 'On': #print 'Cooling on' ThermoData.updateHwEvent('Fan Started') #print('Fan Started Event') #turn the fan on fanHwStatus = 'On' GPIO.output(fan_pin ,1) if fanMode =='A': #Auto pass if fanMode =='O': #Off fanHwStatus = 'Off' coolingHwStatus = 'Off' heatingHwStatus = 'Off' if offHwStatus != 'On': ThermoData.updateHwEvent('System Stopped') #print('System Off Event') offHwStatus = 'On' shutOffHVAC() except: ThermoHardwareLogger.exception('Exception Occurred in ThermoHardware controlHVAC')
def controlHVAC(desiredTemp, hwTemp, fanMode='O'): global coolingHwStatus global heatingHwStatus global fanHwStatus global offHwStatus #print('coolingHwStatus: ', coolingHwStatus) #print('heatingHwStatus: ', heatingHwStatus) #print('fanHwStatus: ', fanHwStatus) #print('offHwStatus: ', offHwStatus) try: if fanMode == 'H': #heating fanHwStatus = 'Off' offHwStatus = 'Off' #turn off the other pins incase they were already on GPIO.output(cool_pin, 0) GPIO.output(fan_pin, 0) #compare the temp and either keep running or turn off if desiredTemp > hwTemp: if heatingHwStatus != 'On': ThermoData.updateHwEvent('Heating Started') #print('Heating Started Event') #ThermoData.updateHwEvent('Heating Started') GPIO.output(heat_pin, 1) heatingHwStatus = 'On' if desiredTemp + 1 < hwTemp: if heatingHwStatus != 'Off': ThermoData.updateHwEvent('Heating Stopped') #print('Heating stopped Event') heatingHwStatus = 'Off' GPIO.output(heat_pin, 0) if fanMode == 'C': #cooling fanHwStatus = 'Off' offHwStatus = 'Off' #turn off the other pins incase they were already on GPIO.output(heat_pin, 0) GPIO.output(fan_pin, 0) #compare the temp and either keep running or turn off if desiredTemp < hwTemp: if coolingHwStatus != 'On': ThermoData.updateHwEvent('Cooling Started') #print('Cooling Started Event') GPIO.output(cool_pin, 1) coolingHwStatus = 'On' if desiredTemp - 1 > hwTemp: if coolingHwStatus != 'Off': #print 'Cooling Off' ThermoData.updateHwEvent('Cooling Stopped') coolingHwStatus = 'Off' #print('Cooling Stopped Event') GPIO.output(cool_pin, 0) if fanMode == 'F': #Fan offHwStatus = 'Off' #turn off the other pins incase they were already on GPIO.output(cool_pin, 0) GPIO.output(fan_pin, 0) if fanHwStatus != 'On': #print 'Cooling on' ThermoData.updateHwEvent('Fan Started') #print('Fan Started Event') #turn the fan on fanHwStatus = 'On' GPIO.output(fan_pin, 1) if fanMode == 'A': #Auto pass if fanMode == 'O': #Off fanHwStatus = 'Off' coolingHwStatus = 'Off' heatingHwStatus = 'Off' if offHwStatus != 'On': ThermoData.updateHwEvent('System Stopped') #print('System Off Event') offHwStatus = 'On' shutOffHVAC() except: ThermoHardwareLogger.exception( 'Exception Occurred in ThermoHardware controlHVAC')