コード例 #1
0
ファイル: ThermoGui.py プロジェクト: tinkerjs/Pi-Thermostat
def getDBInformation():
    #retrieves the data from the DB and sets the values ot the UI components
    fcgQuery = ThermoData.getForecastData()
    currentForecast = (fcgQuery.fc_4dforecast)
    text_currentForecast.delete('1.0', '5.0')
    text_currentForecast.insert('1.0', currentForecast)
    outsideTempVal.set(fcgQuery.fc_outsidetemp)
    outsideHumidVal.set(fcgQuery.fc_outsidehumidity)

    rtgQuery = ThermoData.getRealtimeData()
    currTempVal.set(rtgQuery.rt_currenttemp)
    currHumidVal.set(rtgQuery.rt_humidity)
    desTempVal.set(rtgQuery.rt_destemp)
    dbFanMode = rtgQuery.rt_fanmode
    if dbFanMode == 'H':
        airSelectionVal.set(0)
    if dbFanMode == 'C':
        airSelectionVal.set(1)
    if dbFanMode == 'F':
        airSelectionVal.set(2)
    if dbFanMode == 'O':
        airSelectionVal.set(3)
    if dbFanMode == 'A':
        airSelectionVal.set(4)
    utcTimeValue = (rtgQuery.rt_datetime)
    currentTimeValue = utcTimeValue.astimezone(central)
    currentDate.set(currentTimeValue.strftime('%a %b %d %Y'))
    currentTime.set(currentTimeValue.strftime('%I:%M %p'))
    rootWindow.after(5000, getDBInformation)
コード例 #2
0
ファイル: ThermoGui.py プロジェクト: tinkerjs/Pi-Thermostat
def getDBInformation():
    #retrieves the data from the DB and sets the values ot the UI components
    fcgQuery = ThermoData.getForecastData()
    currentForecast = (fcgQuery.fc_4dforecast)
    text_currentForecast.delete('1.0','5.0')
    text_currentForecast.insert('1.0',currentForecast)
    outsideTempVal.set(fcgQuery.fc_outsidetemp)
    outsideHumidVal.set(fcgQuery.fc_outsidehumidity)
    
    rtgQuery = ThermoData.getRealtimeData()
    currTempVal.set(rtgQuery.rt_currenttemp)
    currHumidVal.set(rtgQuery.rt_humidity)
    desTempVal.set(rtgQuery.rt_destemp)
    dbFanMode = rtgQuery.rt_fanmode
    if dbFanMode == 'H':
        airSelectionVal.set(0)
    if dbFanMode == 'C':
        airSelectionVal.set(1)
    if dbFanMode == 'F':
        airSelectionVal.set(2)
    if dbFanMode == 'O':
        airSelectionVal.set(3)
    if dbFanMode == 'A':
        airSelectionVal.set(4)
    utcTimeValue=(rtgQuery.rt_datetime)
    currentTimeValue = utcTimeValue.astimezone(central)
    currentDate.set(currentTimeValue.strftime('%a %b %d %Y'))
    currentTime.set(currentTimeValue.strftime('%I:%M %p'))
    rootWindow.after(5000,getDBInformation)
コード例 #3
0
def writeTempHumid(hwTemp,hwHumidity):
    try:
        rtwQuery = ThermoData.getRealtimeData()
        rtwQuery.rt_currenttemp = hwTemp
        #print(hwTemp)
        rtwQuery.rt_humidity = hwHumidity
        
        #print(hwHumidity)
        #logging.info('300: writeTempHumid - T:{0} H{1}'.format(hwTemp,hwHumidity))
        ThermoData.updateRealTimeData(rtwQuery)
        #logging.info('300: writeTempHumid - db updated - H:{0} T{1}'.format(hwHumidity,hwTemp))
    except:
        ThermoHardwareLogger.exception('Exception Occurred in ThermoHardware writeTempHumid')
コード例 #4
0
def writeTempHumid(hwTemp, hwHumidity):
    try:
        rtwQuery = ThermoData.getRealtimeData()
        rtwQuery.rt_currenttemp = hwTemp
        #print(hwTemp)
        rtwQuery.rt_humidity = hwHumidity

        #print(hwHumidity)
        #logging.info('300: writeTempHumid - T:{0} H{1}'.format(hwTemp,hwHumidity))
        ThermoData.updateRealTimeData(rtwQuery)
        #logging.info('300: writeTempHumid - db updated - H:{0} T{1}'.format(hwHumidity,hwTemp))
    except:
        ThermoHardwareLogger.exception(
            'Exception Occurred in ThermoHardware writeTempHumid')
コード例 #5
0
def getDBInfo():
    try: 
        rtrQuery = ThermoData.getRealtimeData()
        dbFanMode = rtrQuery.rt_fanmode
        dbDesTemp = rtrQuery.rt_destemp
        return dbFanMode,dbDesTemp
    except:
        ThermoHardwareLogger.exception('Exception Occurred in ThermoHardware getDBInfo')
コード例 #6
0
def getDBInfo():
    try:
        rtrQuery = ThermoData.getRealtimeData()
        dbFanMode = rtrQuery.rt_fanmode
        dbDesTemp = rtrQuery.rt_destemp
        return dbFanMode, dbDesTemp
    except:
        ThermoHardwareLogger.exception(
            'Exception Occurred in ThermoHardware getDBInfo')
コード例 #7
0
ファイル: ThermoGui.py プロジェクト: tinkerjs/Pi-Thermostat
def setAirMode():
    #print airSelectionVal.get()
    rtgQuery = ThermoData.getRealtimeData()
    if airSelectionVal.get() == 0:
        rtgQuery.rt_fanmode ='H'
        radio_airSelectionCool.configure(state='disabled')
        radio_airSelectionFan.configure(state='disabled')
    if airSelectionVal.get() == 1:
        rtgQuery.rt_fanmode = 'C'
        radio_airSelectionHeat.configure(state='disabled')
        radio_airSelectionFan.configure(state='disabled')
    if airSelectionVal.get() == 2:
        rtgQuery.rt_fanmode = 'F'
        radio_airSelectionHeat.configure(state='disabled')
        radio_airSelectionCool.configure(state='disabled')
    if airSelectionVal.get() == 3:
        rtgQuery.rt_fanmode = 'O'
        radio_airSelectionHeat.configure(state='normal')
        radio_airSelectionCool.configure(state='normal')
        radio_airSelectionFan.configure(state='normal')
    if airSelectionVal.get() == 4:
        rtGQuery.rt_fanmode = 'A'
    ThermoData.updateRealTimeData(rtgQuery)
コード例 #8
0
ファイル: ThermoGui.py プロジェクト: tinkerjs/Pi-Thermostat
def setAirMode():
    #print airSelectionVal.get()
    rtgQuery = ThermoData.getRealtimeData()
    if airSelectionVal.get() == 0:
        rtgQuery.rt_fanmode = 'H'
        radio_airSelectionCool.configure(state='disabled')
        radio_airSelectionFan.configure(state='disabled')
    if airSelectionVal.get() == 1:
        rtgQuery.rt_fanmode = 'C'
        radio_airSelectionHeat.configure(state='disabled')
        radio_airSelectionFan.configure(state='disabled')
    if airSelectionVal.get() == 2:
        rtgQuery.rt_fanmode = 'F'
        radio_airSelectionHeat.configure(state='disabled')
        radio_airSelectionCool.configure(state='disabled')
    if airSelectionVal.get() == 3:
        rtgQuery.rt_fanmode = 'O'
        radio_airSelectionHeat.configure(state='normal')
        radio_airSelectionCool.configure(state='normal')
        radio_airSelectionFan.configure(state='normal')
    if airSelectionVal.get() == 4:
        rtGQuery.rt_fanmode = 'A'
    ThermoData.updateRealTimeData(rtgQuery)
コード例 #9
0
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')
コード例 #10
0
ファイル: ThermoGui.py プロジェクト: tinkerjs/Pi-Thermostat
def updateDesTemp():
    rtuQuery = ThermoData.getRealtimeData()
    rtuQuery.rt_destemp = desTempVal.get()
    ThermoData.updateRealTimeData(rtuQuery)
コード例 #11
0
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')
コード例 #12
0
ファイル: ThermoGui.py プロジェクト: tinkerjs/Pi-Thermostat
def updateDesTemp():
    rtuQuery = ThermoData.getRealtimeData()
    rtuQuery.rt_destemp = desTempVal.get()
    ThermoData.updateRealTimeData(rtuQuery)