Example #1
0
def heater_control(temp):
    global heater_state
    #checks to see if current temp should result in heater on or off
    templow  = float(set_dic['heater_templow'])
    temphigh = float(set_dic['heater_templow'])  ## using templow here is not a mistake, plan is to add buffer zones or some something
    print(" ~ ~ ~ heater controll function started ~ ~ ~")
    print("temp = " + temp)
    print(" templow = " + templow)
    print(" temphigh = " + temphigh)
    print("Use Fans = " + str(use_fans))
    print("heater state = " + str(heater_state))
    # if too cool
    if temp < templow and heater_state != 'on':
        message = "It's cold,  temp is" + str(temp) + " degrees! the low limit is " + str(templow) + " so turning heater on."
        if heater_state == 'unknown':
            message = "Script initialised, it's " + str(temp) + " degrees! the low limit is " + str(templow) + " so checking heater's on"
        pigrow_defs.write_log(script, message,loc_dic['loc_switchlog'])
        heater_on.heater_on(set_dic, loc_dic['loc_switchlog'])
        heater_state = 'on'
    # if too hot
    elif temp > temphigh and heater_state != 'off':
        print(" temp greater than temphigh and the heater is off ")
        message = "it's warm, temp is " + str(temp) + " degrees, the high limit is " + str(temphigh) + " so turning heater off"
        if heater_state == 'unknown':
            message = "Script initialised, it's " + str(temp) + " degrees! the low limit is " + str(templow) + " so checking heater's off"
        pigrow_defs.write_log(script, message,loc_dic['loc_switchlog'])
        heater_off.heater_off(set_dic, loc_dic['loc_switchlog'])
        heater_state = 'off'
    else:
        message = "doing nothing, it's " + str(temp) + " degrees and the heater is " + heater_state
        #print(" --not worth logging but, " + message)
    print("")
    print(" ~ ~ ~ heater controll function finished ~ ~ ~")
Example #2
0
def heater_control(temp, use_fans=True):
    global heater_state
    # checks to see if current temp should result in heater on or off
    templow = float(set_dic['heater_templow'])
    # plan is to add buffer zones or some something
    temphigh = float(set_dic['heater_templow'])
    if temp < templow and heater_state != 'on':
        message = "It's cold,  temp is" + \
            str(temp) + " degrees! the low limit is " + \
            str(templow) + " so turning heater on."
        if heater_state == 'unknown':
            message = "Script initialised, it's " + \
                str(temp) + " degrees! the low limit is " + \
                str(templow) + " so checking heater's on"
        pigrow_defs.write_log(script, message, loc_dic['loc_switchlog'])
        heater_on.heater_on(set_dic, loc_dic['loc_switchlog'])
        if use_fans == True:
            fans_on.fans_on(set_dic, loc_dic['loc_switchlog'])
        heater_state = 'on'
    elif temp > temphigh and heater_state != 'off':
        message = "it's warm, temp is " + \
            str(temp) + " degrees, the high limit is " + \
            str(temphigh) + " so turning heater off"
        if heater_state == 'unknown':
            message = "Script initialised, it's " + \
                str(temp) + " degrees! the low limit is " + \
                str(templow) + " so checking heater's off"
        pigrow_defs.write_log(script, message, loc_dic['loc_switchlog'])
        heater_off.heater_off(set_dic, loc_dic['loc_switchlog'])
        if use_fans == True:
            fans_off.fans_off(set_dic, loc_dic['loc_switchlog'])
        heater_state = 'off'
    else:
        message = "doing nothing, it's " + \
            str(temp) + " degrees and the heater is " + heater_state