 volatile int subMsgReceived = LOW;
 volatile int topicMsgSent   = LOW;
 volatile int relaystatus    = LOW;
+volatile int relayReady     = LOW;
 
 int vdd;
 

    wifi_connect();
  }


  if ( subMsgReceived == HIGH ) {
    subMills = (millis() - startMills) - wifiMills ;
    if (DEBUG_PRINT) {
      Serial.print("sub received ---> ");
      Serial.println(subMills);
    }
    sendlightcmd();
  }

  if ( topicMsgSent == HIGH ) {

    Serial.println(receivedpayload);
  }

  char json[] = "{\"LIGHT\":1,\"READY\":1}";
  receivedpayload.toCharArray(json, 100);
  StaticJsonBuffer<100> jsonBuffer;
  JsonObject& root = jsonBuffer.parseObject(json);

  if (!root.success()) {
    if (DEBUG_PRINT) {
      Serial.println("parseObject() failed");
    }
    subMsgReceived = HIGH;
    relayReady = LOW ;
    return;
  }

  int LIGHT = root["LIGHT"];
  int READY = root["READY"];

  if ( READY == 1 ) {
    if ( LIGHT == 1 ) {
      relaystatus = 1;
    }
    if ( LIGHT == 0) {
      relaystatus = 0;
    }
    subMsgReceived = HIGH;
    relayReady = HIGH ;
  }

  if ( READY == 0 ) {
    subMsgReceived = HIGH;
    relayReady = LOW ;
  }

  if (DEBUG_PRINT) {
    Serial.print("mqtt sub => ");
    Serial.print("ready ==> ");
    Serial.print(READY);
    Serial.print(" relaystatus => ");
    Serial.println(LIGHT);
  }

}

boolean reconnect()
