// Try to get the new temp.
wifi_client.connect("192.168.0.113", 1884);
delay(500);
bool waited = 0;
for(int i=0; i < 12 && (!wifi_client.connected() || !wifi_client.available()); i++){
Serial.print(i);
Serial.print("... ");
delay(500);
waited = true;
}
if( waited ){ Serial.println(); }
StaticJsonDocument<32> jDoc;
if (wifi_client.available()) {
deserializeJson(jDoc, wifi_client);
foo = jDoc["foo"];
Serial.print(current_foo);
Serial.print(" -> ");
Serial.println(foo);
if(foo> 0 & current_foo == 0 ){ current_foo = foo; }
}
else {
Serial.println("No data from 1884");
}
wifi_client.stop();
A problem with this is that you can only see the latest retained message on the topic in MQTT therefore the value must represent the desired state rather than an instruction to change state; comparing foo to the current_foo determines whether an action must be taken.
The capability was added in Arduino IDE 2.x, but if you are still using Arduino IDE 1.x then indeed the Library Manager didn't provide an uninstall capability at that time and the only way to uninstall libraries is by manually deleting their installation folder as you did.