 #include <ESP8266WiFi.h>
 #include <PubSubClient.h>
+#include <ArduinoJson.h>
 
 #define _IS_MY_HOME
 // wifi

    Serial.println(receivedpayload);
  }

  if ( receivedpayload == "{\"LIGHT\":1}") {
    relaystatus = 1 ;
  }
  else if ( receivedpayload == "{\"LIGHT\":0}") {
    relaystatus = 0 ;
  }

  if (DEBUG_PRINT) {
    Serial.print("mqtt sub => ");
    Serial.print("relaystatus => ");
    Serial.println(relaystatus);
  }
  subMsgReceived = HIGH;
}

boolean reconnect()

    wifi_connect();
  }

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

  if (( subMsgReceived == HIGH ) && ( relayReady == LOW )) {
    subMills = (millis() - startMills) - wifiMills ;
    if (DEBUG_PRINT) {
      Serial.print("sub received : not ready ---> ");
      Serial.println(subMills);
    }
    goingToSleepWithFail();
  }

  if ( topicMsgSent == HIGH ) {
