mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-10 15:11:59 +01:00
[miio] avoid Invalid URI host: null error (#8867)
* [miio] avoid Invalid URI host: null error Signed-off-by: Marcel Verpaalen <marcel@verpaalen.com>
This commit is contained in:
parent
7d484831c3
commit
472c0fd960
@ -137,14 +137,22 @@ public class CloudConnector {
|
|||||||
mapCountry = country.trim().toLowerCase();
|
mapCountry = country.trim().toLowerCase();
|
||||||
mapUrl = cl.getMapUrl(mapId, mapCountry);
|
mapUrl = cl.getMapUrl(mapId, mapCountry);
|
||||||
}
|
}
|
||||||
@Nullable
|
if (mapUrl.isBlank()) {
|
||||||
RawType mapData = HttpUtil.downloadData(mapUrl, null, false, -1);
|
logger.debug("Cannot download map data: Returned map URL is empty");
|
||||||
if (mapData != null) {
|
|
||||||
return mapData;
|
|
||||||
} else {
|
|
||||||
logger.debug("Could not download '{}'", mapUrl);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
RawType mapData = HttpUtil.downloadData(mapUrl, null, false, -1);
|
||||||
|
if (mapData != null) {
|
||||||
|
return mapData;
|
||||||
|
} else {
|
||||||
|
logger.debug("Could not download '{}'", mapUrl);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
logger.debug("Error downloading map: {}", e.getMessage());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCredentials(@Nullable String username, @Nullable String password, @Nullable String country) {
|
public void setCredentials(@Nullable String username, @Nullable String password, @Nullable String country) {
|
||||||
|
@ -160,7 +160,8 @@ public class MiCloudConnector {
|
|||||||
if (response.getAsJsonObject().has("result") && response.getAsJsonObject().get("result").isJsonObject()) {
|
if (response.getAsJsonObject().has("result") && response.getAsJsonObject().get("result").isJsonObject()) {
|
||||||
JsonObject jo = response.getAsJsonObject().get("result").getAsJsonObject();
|
JsonObject jo = response.getAsJsonObject().get("result").getAsJsonObject();
|
||||||
if (jo.has("url")) {
|
if (jo.has("url")) {
|
||||||
return jo.get("url").getAsString();
|
String mapUrl = jo.get("url").getAsString();
|
||||||
|
return mapUrl != null ? mapUrl : "";
|
||||||
} else {
|
} else {
|
||||||
errorMsg = "Could not get url";
|
errorMsg = "Could not get url";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user