 
   TickType_t xLastWakeTime;
 
-  if ( defaultTimersLoaded() )
-  {
-    ESP_LOGI( TAG, "Default timers loaded." );
-  }
-  else
-  {
+  if ( defaultTimersLoaded() ) ESP_LOGI( TAG, "Default timers loaded." );
+  else {
     ESP_LOGI( TAG, "No timers loaded." );
     setEmptyTimers();
   }

  }
}

bool defaultTimersLoaded()
{
  //find 'default.aqu' on selected storage and if present load the timerdata from this file
  //return true on success
  //return false on error

  if ( !FFat.exists( defaultTimerFile ) )
  {
    ESP_LOGI( TAG, "No default timer file found. [%s]", defaultTimerFile );
    return false;
  }

  File f = FFat.open( defaultTimerFile, "r" );

  if ( !f.available() )
  {
    ESP_LOGI( TAG, "Error opening default timer file. [%s]", defaultTimerFile );
    return false;
  }
  String lineBuf;
  byte currentTimer = 0;
  byte thisChannel;
  while ( f.position() < f.size() )
  {
    lineBuf = f.readStringUntil( '\n' );
    if ( lineBuf.indexOf( "[" ) > -1 )
    {
      String thisChannelStr;
      thisChannelStr = lineBuf.substring( lineBuf.indexOf("[") + 1, lineBuf.indexOf("]") );
      thisChannel = thisChannelStr.toInt();
      currentTimer = 0;
    }
    else if ( currentTimer < MAX_TIMERS - 1 )
    {
      String thisPercentage;
      String thisTime;
      thisTime = lineBuf.substring( 0, lineBuf.indexOf(",") );
      thisPercentage = lineBuf.substring( lineBuf.indexOf(",") + 1 );
      channel[thisChannel].timer[currentTimer].time = thisTime.toInt();
      channel[thisChannel].timer[currentTimer].percentage = thisPercentage.toInt();
      currentTimer++;
      channel[thisChannel].numberOfTimers = currentTimer;
    }

  }
  f.close();
  //add the 24:00 timers ( copy of timer percentage no: 0 )
  for ( thisChannel = 0; thisChannel < NUMBER_OF_CHANNELS; thisChannel++ )
  {
    channel[thisChannel].timer[channel[thisChannel].numberOfTimers].time = 86400;
    channel[thisChannel].timer[channel[thisChannel].numberOfTimers].percentage = channel[thisChannel].timer[0].percentage;
    currentTimer++;
    channel[thisChannel].numberOfTimers = currentTimer;
  }
  return true;
}

void setEmptyTimers()
{
  for ( byte channelNumber = 0; channelNumber < NUMBER_OF_CHANNELS; channelNumber++)
  {
    channel[channelNumber].timer[0].time = 0;
    channel[channelNumber].timer[0].percentage = 0;
    channel[channelNumber].timer[1].time = 86400;
    channel[channelNumber].timer[1].percentage = 0;
    channel[channelNumber].numberOfTimers = 1;
  }
}

void setupDimmerPWMfrequency( const double frequency, const uint8_t numberOfBits )
{
  /* Setup timers and pwm bit depth */
  for ( uint8_t channelNumber = 0; channelNumber < NUMBER_OF_CHANNELS; channelNumber++ )
  {
    ledcActualFrequency = ledcSetup( channelNumber, frequency, numberOfBits );
  }
  ledcMaxValue = ( 0x00000001 << numberOfBits ) - 1;
  ledcNumberOfBits = numberOfBits;

  channel[ 2 ].pin = LED2_PIN;
  channel[ 3 ].pin = LED3_PIN;
  channel[ 4 ].pin = LED4_PIN;
  for ( uint8_t num = 0; num < NUMBER_OF_CHANNELS; num++ ) {
    char NVSKeyName[32];

    snprintf( NVSKeyName, sizeof( NVSKeyName ), "channelname%i", num );
    snprintf( channel[ num ].name, sizeof( channel[ num ].name ), preferences.getString( NVSKeyName, "channelname" ).c_str() );

    snprintf( NVSKeyName, sizeof( NVSKeyName ), "channelcolor%i", num );
    snprintf( channel[ num ].color, sizeof( channel[ num ].color ), preferences.getString( NVSKeyName, "#fffe7a" ).c_str() );

    snprintf( NVSKeyName, sizeof( NVSKeyName ), "channelminimum%i", num );
    channel[ num ].minimumLevel  = preferences.getFloat( NVSKeyName, 0  );

    ledcAttachPin( channel[num].pin, num);
  }

  setupDimmerPWMfrequency( preferences.getDouble( "pwmfrequency", LEDC_MAXIMUM_FREQ ),
                           preferences.getUInt( "pwmdepth", LEDC_NUMBER_OF_BIT ) );
  leds.setState( LIGHTS_AUTO );

  ESP_LOGI( TAG, "Lights running after %.1f seconds.", millis() / 1000.0 );

  xLastWakeTime = xTaskGetTickCount();

  while (1) {

    if ( leds.state() != LIGHTS_AUTO ) {
      lightState_t currentState = leds.state();
      uint16_t pwmValue = ( currentState == LIGHTS_OFF ) ? 0 : ledcMaxValue;
      float percentage = ( pwmValue == 0 ) ? 0 : 100;
      for ( uint8_t num = 0; num < NUMBER_OF_CHANNELS; num++ ) {
        channel[num].currentPercentage = percentage;
        ledcWrite( num, pwmValue );
      }
      while ( leds.state() == currentState ) delay( 100 );
    }
    else {
      struct timeval microSecondTime;
      gettimeofday( &microSecondTime, NULL );

      struct tm *localTime;
      localTime = localtime( &microSecondTime.tv_sec );

      suseconds_t milliSecondsToday = ( localTime->tm_hour       * 3600000U ) +
