Пример #1
0
def humid_contol(humid, use_fans=False):
    global humid_state
    humid_low = float(set_dic['humid_low'])
    if humid < humid_low and humid_state != 'up_on':
        msg = "should turn the humidifer on, it's " + str(
            humid) + " and the low limit is " + str(humid_low)
        if humid_state == 'unknown':
            msg = "Script initialised, humid " + str(
                humid) + ", low limit is " + str(
                    humid_low) + " checking humidifier is on"
        humid_state = 'up_on'
        pigrow_defs.write_log(script, msg, loc_dic['loc_switchlog'])
        humid_on.humid_on(set_dic, loc_dic['loc_switchlog'])
        if use_fans == True:
            fans_on.fans_on(set_dic, loc_dic['loc_switchlog'])
    elif humid > humid_low and humid_state != 'up_off':
        msg = ("should turn the humidifier off, it's " + str(humid) +
               " and the low limit is " + str(humid_low))
        if humid_state == 'unknown':
            msg = "Script initialised, humid " + str(
                humid) + ", low limit is " + str(
                    humid_low) + " checking humidifier is off"
        humid_state = 'up_off'
        pigrow_defs.write_log(script, msg, loc_dic['loc_switchlog'])
        humid_off.humid_off(set_dic, loc_dic['loc_switchlog'])
        if use_fans == True:
            fans_off.fans_off(set_dic, loc_dic['loc_switchlog'])
Пример #2
0
def dehumid_control(humid, use_fans=False):
    global dehumid_state
    humid_high = float(set_dic['humid_high'])
    if humid > humid_high and dehumid_state != 'down_on':
        msg = "should turn dehumidifer on, it's " + str(
            humid) + " and the high limit is " + str(humid_high)
        if dehumid_state == 'unknown':
            msg = "Script initialised, humid " + str(
                humid) + ", the high limit is " + str(
                    humid_high) + " checking it's on"
        dehumid_state = 'down_on'
        pigrow_defs.write_log(script, msg, loc_dic['loc_switchlog'])
        dehumid_on.dehumid_on(set_dic, loc_dic['loc_switchlog'])
        if use_fans == True:
            fans_off.fans_off(set_dic, loc_dic['loc_switchlog'])
    elif humid < humid_high and dehumid_state != 'down_off':
        msg = "should turn dehumid off, it's " + str(
            humid) + " and the high limit is " + str(humid_high)
        if dehumid_state == 'unknown':
            msg = "Script initialised, humid " + str(
                humid) + ", high limit is " + str(
                    humid_high) + " checking it's off"
        dehumid_state = 'down_off'
        pigrow_defs.write_log(script, msg, loc_dic['loc_switchlog'])
        dehumid_off.dehumid_off(set_dic, loc_dic['loc_switchlog'])
        if use_fans == True:
            fans_on.fans_on(set_dic, loc_dic['loc_switchlog'])
Пример #3
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
Пример #4
0
def fan_control(temp,
                humid,
                heat_use_fan=True,
                hum_use_fan=False,
                dehum_use_fan=False):
    global fans_state
    print(" -- Fan controll")
    if heat_use_fan == True:
        temphigh = float(set_dic['heater_temphigh'])
        if temp > temphigh and fans_state != 'on':
            message = "too hot, temp is " + str(
                temp) + " degrees, the high limit is " + str(
                    temphigh) + " so turning the fans on"
            fans_on.fans_on(set_dic, loc_dic['loc_switchlog'])
            fans_state = 'on'
            pigrow_defs.write_log(script, message, loc_dic['loc_switchlog'])
        elif temp < temphigh and fans_state != 'off':
            message = "not too hot, temp is " + str(
                temp) + " degrees, the high limit is " + str(
                    temphigh) + " so turning the fans off"
            fans_off.fans_off(set_dic, loc_dic['loc_switchlog'])
            fans_state = 'off'
            pigrow_defs.write_log(script, message, loc_dic['loc_switchlog'])
    # humid up
    if hum_use_fan == True:
        hum_low = float(set_dic['humid_low'])
        if humid < hum_low and fans_state != 'on':
            message = "not humid enough, humidity is " + str(
                humid) + " %, the low limit is " + str(
                    hum_low) + " so turning the fans on"
            fans_on.fans_on(set_dic, loc_dic['loc_switchlog'])
            fans_state = 'on'
            pigrow_defs.write_log(script, message, loc_dic['loc_switchlog'])
        elif temp > hum_low and fans_state != 'off':
            message = "humid enough, humidity is " + str(
                humid) + " %, the low limit is " + str(
                    hum_low) + " so turning the fans off"
            fans_off.fans_off(set_dic, loc_dic['loc_switchlog'])
            fans_state = 'off'
            pigrow_defs.write_log(script, message, loc_dic['loc_switchlog'])
    # humid down
    if dehum_use_fan == True:
        hum_high = float(set_dic['humid_high'])
        if humid > hum_high and fans_state != 'on':
            message = "too humid, humidity is " + str(
                humid) + " %, the high limit is " + str(
                    hum_high) + " so turning the fans on"
            fans_on.fans_on(set_dic, loc_dic['loc_switchlog'])
            fans_state = 'on'
            pigrow_defs.write_log(script, message, loc_dic['loc_switchlog'])
        elif humid < hum_high and fans_state != 'off':
            message = "humid low enough, humidity is " + str(
                humid) + " %, the high limit is " + str(
                    hum_high) + " so turning the fans off"
            fans_off.fans_off(set_dic, loc_dic['loc_switchlog'])
            fans_state = 'off'
            pigrow_defs.write_log(script, message, loc_dic['loc_switchlog'])