import array ctr = 0 boolSwitch = [0,0,0,0] strSwitch = [] strSwitch.append(parser.get('Switches', 'Switch1')) strSwitch.append(parser.get('Switches', 'Switch2')) strSwitch.append(parser.get('Switches', 'Switch3')) strSwitch.append(parser.get('Switches', 'Switch4')) for val in strSwitch: //check for off in switches if (val == 'off'): boolSwitch[ctr] = 0 //check for Day in switches elif ((day < timenow < night) && val = 'Day'): switch_on(ctr + 1) boolSwitch[ctr] = 1 i = dayHigh #day time temp //failed Day check, night elif (val == 'Day'): switch_off(ctr + 1) boolSwitch = 0 //check for temperature if ((temp2 < i) && val == 'Heat'): switch_on(ctr + 1) boolSwitch[ctr] = 1 //higher temp elif (val == 'heat'): switch_off(1) boolSwitch = 0 //check the next switch ctr++