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
be0b3cf5b9
commit
06e30201e9
@ -137,14 +137,22 @@ public class CloudConnector {
|
||||
mapCountry = country.trim().toLowerCase();
|
||||
mapUrl = cl.getMapUrl(mapId, mapCountry);
|
||||
}
|
||||
@Nullable
|
||||
RawType mapData = HttpUtil.downloadData(mapUrl, null, false, -1);
|
||||
if (mapData != null) {
|
||||
return mapData;
|
||||
} else {
|
||||
logger.debug("Could not download '{}'", mapUrl);
|
||||
if (mapUrl.isEmpty()) {
|
||||
logger.debug("Cannot download map data: Returned map URL is empty");
|
||||
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) {
|
||||
|
@ -160,7 +160,8 @@ public class MiCloudConnector {
|
||||
if (response.getAsJsonObject().has("result") && response.getAsJsonObject().get("result").isJsonObject()) {
|
||||
JsonObject jo = response.getAsJsonObject().get("result").getAsJsonObject();
|
||||
if (jo.has("url")) {
|
||||
return jo.get("url").getAsString();
|
||||
String mapUrl = jo.get("url").getAsString();
|
||||
return mapUrl != null ? mapUrl : "";
|
||||
} else {
|
||||
errorMsg = "Could not get url";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user