   }
 }
 
-void mqttPublishData(bool publishInstant) {
-  // Only run when publishInterval in milliseonds exspires or publishInstant = true
+// MQTT Publish with normal or immediate option.
+void mqttPublishData(bool ignorePublishInterval) {
+  // Only run when publishInterval in milliseonds expires or ignorePublishInterval == true
   unsigned long currentMillis = millis();
-  if (currentMillis - previousMillis >= publishInterval || publishInstant == true) {
-    previousMillis = currentMillis; // save the last time this ran
+  if (currentMillis - previousMillis >= publishInterval || ignorePublishInterval == true) {
+    previousMillis = currentMillis; // Save the last time this ran
     // Check conenction to MQTT server
     if (mqttClient.connected()) {
       // Publish node state data
       publishNodeState();
 
-      // New JSON data method
+      // JSON data method
       StaticJsonBuffer<json_buffer_size> jsonBuffer;
       JsonObject& root = jsonBuffer.createObject();
       // INFO: the data must be converted into a string; a problem occurs when using floats...

        Serial.print(F("JSON Sensor data published to [")), Serial.print(publishSensorJsonTopic), Serial.println("] ");

      Serial.println("JSON Sensor Published");

      // Old legacy method
      // Grab the current state of the sensor
      String strTemp = String(dht.readTemperature()); //Could use String(dht.readTemperature()).c_str()) to do it all in one line
      if (!mqttClient.publish(publishTemperature, String(dht.readTemperature()).c_str())) // Convert dht.readTemperature() to string object, then to char array.
        Serial.print(F("Failed to published to [")), Serial.print(publishTemperature), Serial.print("] ");
      else
        Serial.print(F("Temperature published to [")), Serial.print(publishTemperature), Serial.println("] ");

      String strHumi = String(dht.readHumidity());
      if (!mqttClient.publish(publishHumidity, strHumi.c_str()))
        Serial.print(F("Failed to humidity to [")), Serial.print(publishHumidity), Serial.print("] ");
      else
        Serial.print(F("Humidity published to [")), Serial.print(publishHumidity), Serial.println("] ");

      String strSetpoint = String(targetHeaterTemperature);
      if (!mqttClient.publish(publishSetHeaterTemperature, strSetpoint.c_str(), true)) // retained = true
        Serial.print(F("Failed to target temperature to [")), Serial.print(publishSetHeaterTemperature), Serial.print("] ");
      else
        Serial.print(F("Target temperature published to [")), Serial.print(publishSetHeaterTemperature), Serial.println("] ");

      String strHeaterOutput = String(outputHeaterPoweredStatus);
      if (!mqttClient.publish(publishHeaterOutputState, strHeaterOutput.c_str()))
        Serial.print(F("Failed to output heater state to [")), Serial.print(publishHeaterOutputState), Serial.print("] ");
      else
        Serial.print(F("Output heater state published to [")), Serial.print(publishHeaterOutputState), Serial.println("] ");

      String strCoolerOutput = String(outputCoolerPoweredStatus);
      if (!mqttClient.publish(publishCoolerOutputState, strCoolerOutput.c_str()))
        Serial.print(F("Failed to output cooler state to [")), Serial.print(publishCoolerOutputState), Serial.print("] ");
      else
        Serial.print(F("Output cooler state published to [")), Serial.print(publishCoolerOutputState), Serial.println("] ");
    }}}

// Returns true if heating is required

const char* clientName = secret_clientName; // Client to report to MQTT
const char* mqtt_username = secret_mqtt_username; // MQTT Username
const char* mqtt_password = secret_mqtt_password; // MQTT Password
bool willRetain = true; // MQTT Last Will and Testament
const char* willMessage = "offline"; // MQTT Last Will and Testament Message
const int json_buffer_size = 256;

