Example #1
0
def check_lamp(on_time, off_time):
    current_time = datetime.datetime.now().time()
    msg = 'Script initialised, performing lamp state check;'
    pigrow_defs.write_log(script, msg, loc_dic['loc_switchlog'])
    if True:
        if on_time > off_time:
            if current_time > on_time or current_time < off_time:
                lamp_on.lamp_on(set_dic, loc_dic['loc_switchlog'])
                return 'lamp on', True
            else:
                lamp_off.lamp_off(set_dic, loc_dic['loc_switchlog'])
                return 'lamp off', True

        elif on_time < off_time:
            if current_time > on_time and current_time < off_time:
                lamp_on.lamp_on(set_dic, loc_dic['loc_switchlog'])
                return 'the lamp on', True
            else:
                lamp_off.lamp_off(set_dic, loc_dic['loc_switchlog'])
                return 'the lamp off', True

        elif current_time == on_time:
            return ' - Actually it was a crazy coincidence, exact time match! cron will switch it for us', False
        return 'error', False
Example #2
0
def check_lamp(on_time, off_time):
    current_time = datetime.datetime.now().time()
    msg = 'Script initialised, performing lamp state check;'
    pigrow_defs.write_log(script, msg, loc_dic['loc_switchlog'])
    if True:
        if on_time > off_time:
            if current_time > on_time or current_time < off_time:
                lamp_on.lamp_on(set_dic, loc_dic['loc_switchlog'])
                return 'a lamp on', True
            else:
                lamp_off.lamp_off(set_dic, loc_dic['loc_switchlog'])
                return 'a lamp off', True

        elif on_time < off_time:
            if current_time > on_time and current_time < off_time:
                lamp_on.lamp_on(set_dic, loc_dic['loc_switchlog'])
                return 'the lamp on', True
            else:
                lamp_off.lamp_off(set_dic, loc_dic['loc_switchlog'])
                return 'the lamp off', True

        elif current_time == on_time:
            return 'changing', False
        return 'magness', False