   sendmqttMsg(reporting_topic, json, false);
 }
 
+void ICACHE_RAM_ATTR send_ac_cmd()
+{
+  DynamicJsonBuffer jsonBuffer;
+  JsonObject& root = jsonBuffer.createObject();
+  root["AC"] = !digitalRead(COOL_PIN);
+  String json;
+  root.printTo(json);
+
+  sendmqttMsg(topic_ac_cmd, json, true);
+}
+
 void ICACHE_RAM_ATTR callback(char* intopic, byte* inpayload, unsigned int length)
 {
 }
 
+bool verifytls()
+{
+
+  if (!sslclient.connect(mqtt_server, 8883))
+  {
+    return false;
+  }
+
+  if (sslclient.verify(MQTT_FINGERPRINT, MQTT_SERVER_CN))
+  {
+    sslclient.stop();
+    return true;
+  }
+  else
+  {
+    sslclient.stop();
+    return false;
+  }
+}
+
 boolean reconnect()
 {
   if (!client.connected())
   {
-    if (client.connect((char*) clientName.c_str()))
-    {
-      Serial.println("[MQTT] mqtt connected");
-    }
-    else
-    {
-      Serial.print("[MQTT] mqtt failed, rc=");
-      Serial.println(client.state());
-    }
+   if (verifytls())
+   {
+      if (client.connect((char*) clientName.c_str(), MQTT_USER, MQTT_PASS))
+      {
+         if ( ResetInfo == LOW) {
+            client.publish(hellotopic, (char*) getResetInfo.c_str());
+            ResetInfo = HIGH;
+         } else {
+            client.publish(hellotopic, "hello again 1 from nestbridge");
+         }
+         Serial.println("[MQTT] mqtt connected");
+      }
+      else
+      {
+         Serial.print("[MQTT] mqtt failed, rc=");
+         Serial.println(client.state());
+      }
+   }
   }
   return client.connected();
 }

const int timeZone = 9;
time_t prevDisplay = 0;

void ICACHE_RAM_ATTR callback(char* intopic, byte* inpayload, unsigned int length);
WiFiClient wifiClient;
PubSubClient client(mqtt_server, 1883, callback, wifiClient);
WiFiUDP udp;

volatile bool bnest_isr = false;

void ICACHE_RAM_ATTR nest_isr() {
  bnest_isr = true;
}

bool ICACHE_RAM_ATTR sendmqttMsg(const char* topictosend, String payloadtosend, bool retain = false)

	clientName += macToStr(mac);
	clientName += "-";
	clientName += String(micros() & 0xff, 16);

   getResetInfo = "hello from nestbridge ";
   getResetInfo += ESP.getResetInfo().substring(0, 50);
	
	configTime(9 * 3600, 0, "pool.ntp.org", "time.nist.gov");
	
