         toggleLamp();
       }
     }
-    // otherwise ensure interior light is off.
-    else {
+    // otherwise if brightness is less than 3% or greater than 11% ensure interior light is off.
+    else if (brightness < 3 || brightness > 11) {
       if (lampState) {
         if (Debugging) {
           debugger.println("Turning off interior light.");

  }
  esp.wifiCb.attach(&wifiCb);
  esp.wifiConnect(wHost, wPass);

  lcdWrite("Initializing...", "WIFI Connecting");

  /**
   * Setup pin modes


// Misc Settings
const unsigned long millisPerDay    = 86400000; // Milliseconds per day
const unsigned long debounceWait    =      200; // Door debounce timer (200 ms)
const unsigned long ledBlinkRate    =      250; // Delay between LED blinks (1/4 sec)
const unsigned long lcdChange       =     5000; // How often to change LCD pages (5 sec)
const unsigned long lightReadRate   =     1000; // How often to read light level (1 sec)
const unsigned long remoteOverride  =   600000; // Length of time to lockout readings. (10 min)
const unsigned long publishInterval =    60000; // How often to publish light/temp sensor readings. (1 min)
const int           fanThreshold    =       78; // When temperature (Farenheit) exceeds this threshold, turn on fan
const int           heaterThreshold =       36; // When temperature (Farenheit) is below this threshold, turn on water heater
const int           lsLow           =        0; // Light Sensor lowest reading
const int           lsHigh          =      900; // Light Sensor highest reading

// Night time lockout to prevent reaction to light sensor readings if an exterior light source causes
// a reading otherwise bright enough to activate the interior light and/or door.
const boolean       nightLock      =      true; // Enable night time lockout


/*************************************************
       DO   NOT   EDIT   BELOW   THIS   LINE
 *************************************************/
 
// Runtime variables
int           nightLockStart     =    22; // Hour (in 24hr time) to initiate night time lockout (10pm)
int           nightLockEnd       =     4; // Hour (in 24hr time) to end night time lockout (4am)
unsigned long lastPublish        =     0;
unsigned long lastDebounce       =     0;
unsigned long lastLightRead      =     0;
unsigned long lastRTCSync        =     0;
unsigned long lastLEDBlink       =     0;
unsigned long remoteLockStart    =     0;
unsigned long lastLCDChange      =     0;
String        doorState          =    ""; // Values will be one of: closed, closing, open, opening
String        doorStatePrev      =    "";
boolean       heaterState        = false;
boolean       lampState          = false;
boolean       fanState           = false;
float         tempC              =     0;
float         tempF              =     0;
int           brightness         =     0;
int           doorTopVal         =     0;
int           doorTopVal2        =     0;
int           doorTopState       =     0;
int           doorTopPrev        =     0;
int           doorBottomVal      =     0;
int           doorBottomVal2     =     0;
int           doorBottomState    =     0;
int           doorBottomPrev     =     0;
int           lcdPage            =     0; // Toggle between LCD page states
uint32_t      bootTime           =     0;

RTC_DS1307 RTC;
OneWire ds(tempSense);
LiquidCrystal lcd(lcd_4, lcd_6, lcd_11, lcd_12, lcd_13, lcd_14);

#if Debugging
  ESP esp(&espPort, &debugger, chpdPin);
#else
  ESP esp(&espPort, chpdPin);
#endif

MQTT mqtt(&esp);
boolean wifiConnected = false;
