         break;
       }
     }
-    Serial.println();
 
     SetDevice(index, device);
 
     message += "device: " + http_server.arg("device") + "\n";
     Serial.println(message);
+
+    // Force reconnect to MQTT so we subscribe to any new addreses.
+    mqtt_client.disconnect();
   }
 
   http_server.send(200, "text/plain", message);

      io_pins_buffer[strlen(io_pins_buffer)] = ',';
    }

    Serial.println(io_pins_buffer);
    Serial.println();

    unsigned int pin_num = 0, pin_buffer_pointer = 0;
    memset(pin_buffer, '\0', 4);
    for (unsigned int i = 0; i < strlen(io_pins_buffer); ++i) {
      if (io_pins_buffer[i] == ',') {
        Serial.println(pin_buffer);
        device.io_pins[pin_num++] = atoi(pin_buffer);
        memset(pin_buffer, '\0', 4);
        pin_buffer_pointer = 0;

  brokers.ParseMDnsAnswer(answer);
}
mdns::MDns my_mdns(NULL, NULL, answerCallback);


// MQTT
