 			// Listen for configuration
 			LOG_PRINTFLN("Waiting the configuration for %lu ms", MQTT_LISTEN_TIME_MS);
 			mqtt->yield(MQTT_LISTEN_TIME_MS);
-			rc = mqtt->unsubscribe(topic);
-			if (rc != MqttClient::Error::SUCCESS) {
-				LOG_PRINTFLN("ERROR, Unsubscribe, rc:%i", rc);
-			} else {
-				// Success
-				res = true;
+			// Configuration change might cause the disconnect
+			if (mqtt->isConnected()) {
+				rc = mqtt->unsubscribe(topic);
+				if (rc != MqttClient::Error::SUCCESS) {
+					LOG_PRINTFLN("ERROR, Unsubscribe, rc:%i", rc);
+				} else {
+					// Success
+					res = true;
+				}
 			}
 		}
-	}
-	if (!res) {
-		LOG_PRINTFLN("Drop connection");
-		mqtt->disconnect();
+		if (!res && mqtt->isConnected()) {
+			LOG_PRINTFLN("Drop connection");
+			mqtt->disconnect();
+		}
 	}
 	return res;
 }
 
 void processMessageConfig(MqttClient::MessageData& md) {
+	bool changed = false;
 	const MqttClient::Message& msg = md.message;
 	char payload[msg.payloadLen + 1];
 	memcpy(payload, msg.payload, msg.payloadLen);

void loop() {
	check();
	if (!mqtt->isConnected()) {
		// Not connected
		// Clean buffers and give some time for network
		mqtt->yield();
		// Connect

unsigned long updateConfigTs						= 0;
int connectCounter									= 0;
bool firstPublish									= false;
bool firstUpdateConfig								= false;

//// DECLARATION ////
void(* reset) (void) = 0;//declare reset function at address 0
