     else // U_SPIFFS
       type = "filesystem";
 
+    char buff[256];
+    snprintf(buff, sizeof(buff), "[%s] %s OTA re-programming started.", pname, type.c_str());
+
+    Serial.println(buff);
+    client.publish(log_topic, buff);
+    client.loop();
+
     // NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
-    Serial.println("Start updating " + type);
   });
 
   ArduinoOTA.onEnd([]() {
-    Serial.println("\nEnd");
+    char buff[256];
+    snprintf(buff, sizeof(buff), "[%s] OTA re-programming completed. Rebooting.", pname);
+
+    Serial.println(buff);
+    client.publish(log_topic, buff);
+    client.loop();
+
+    client.disconnect();
   });
 
   ArduinoOTA.onError([](ota_error_t error) {

  ota = true;
}

void WiFiEvent(WiFiEvent_t event)
{
  switch (event) {


void setup()
{
  const char * f = __FILE__;
  char * p = rindex(f, '/');
  if (p)
    strncpy(pname, p + 1, sizeof(pname));

  p = index(pname, '.');
  if (p)
    *p = 0;

  Serial.begin(115200);
  Serial.print("\n\n\n\nStart ");
  Serial.print(pname);
  Serial.println(" " __DATE__ " " __TIME__ );

  WiFi.onEvent(WiFiEvent);

