   // check the fingerprint of io.adafruit.com's SSL cert
   verifyFingerprint();
 #endif
-
-  // init MQTT
+  sprintf(ARILUX_MQTT_STATE_STATE_TOPIC, DEFARILUX_MQTT_STATE_STATE_TOPIC,chipid);
+  sprintf(ARILUX_MQTT_STATE_COMMAND_TOPIC,DEFARILUX_MQTT_STATE_COMMAND_TOPIC,chipid);
+  sprintf(ARILUX_MQTT_BRIGHTNESS_STATE_TOPIC,DEFARILUX_MQTT_BRIGHTNESS_STATE_TOPIC,chipid);
+  sprintf(ARILUX_MQTT_BRIGHTNESS_COMMAND_TOPIC,DEFARILUX_MQTT_BRIGHTNESS_COMMAND_TOPIC,chipid);
+  sprintf(ARILUX_MQTT_COLOR_STATE_TOPIC,DEFARILUX_MQTT_COLOR_STATE_TOPIC,chipid);
+  sprintf(ARILUX_MQTT_COLOR_COMMAND_TOPIC,DEFARILUX_MQTT_COLOR_COMMAND_TOPIC,chipid);
+  sprintf(ARILUX_MQTT_WHITE_STATE_TOPIC,DEFARILUX_MQTT_WHITE_STATE_TOPIC,chipid);
+  sprintf(ARILUX_MQTT_WHITE_COMMAND_TOPIC,DEFARILUX_MQTT_WHITE_COMMAND_TOPIC,chipid);
   mqttClient.setServer(MQTT_SERVER_IP, MQTT_SERVER_PORT);
   mqttClient.setCallback(callback);
   connectMQTT();
 
   // set hostname and start OTA
-  ArduinoOTA.setHostname("arilux");
+  ArduinoOTA.setHostname(host);
+   ArduinoOTA.onStart([]() {
+      arilux.setAll(0,0,0,0,0);  
+  
+  });
+  ArduinoOTA.onError([](ota_error_t error) {
+    Serial.printf("Error[%u]: ", error);
+    if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
+    else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
+    else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
+    else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
+    else if (error == OTA_END_ERROR) Serial.println("End Failed");
+  });
   ArduinoOTA.begin();
 }
 


    if (arilux.setColor(payload.substring(0, firstIndex).toInt(), payload.substring(firstIndex + 1, lastIndex).toInt(), payload.substring(lastIndex + 1).toInt()))
      cmd = ARILUX_CMD_COLOR_CHANGED;
  }
}

/*

//  SETUP() AND LOOP()
///////////////////////////////////////////////////////////////////////////
void setup() {
  char host[64];
  Serial.begin(115200);
  delay(500);
#ifdef DEBUG_TELNET
  // start the Telnet server
  telnetServer.begin();
  telnetServer.setNoDelay(true);
#endif
  sprintf(chipid, "%08X", ESP.getChipId());
  sprintf(host, HOST, chipid);
  Serial.print("hostname:");
  Serial.println(host);
  WiFi.hostname(host);

  // setup the Wi-Fi
  setupWiFi();
