Skip to content

Commit 5ac2780

Browse files
authored
fix offline when image not available (openhab#18066)
Signed-off-by: Mark Herwege <[email protected]>
1 parent ffa2d17 commit 5ac2780

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

bundles/org.openhab.binding.speedtest/src/main/java/org/openhab/binding/speedtest/internal/SpeedtestHandler.java

+12-6
Original file line numberDiff line numberDiff line change
@@ -365,13 +365,19 @@ private void getSpeed() {
365365
isp = tmpCont.getIsp();
366366
interfaceInternalIp = tmpCont.getInterface().getInternalIp();
367367
interfaceExternalIp = tmpCont.getInterface().getExternalIp();
368-
resultUrl = tmpCont.getResult().getUrl();
369-
String url = String.valueOf(resultUrl) + ".png";
370-
logger.debug("Downloading result image from: {}", url);
371-
RawType image = HttpUtil.downloadImage(url);
372-
if (image != null) {
373-
resultImage = image;
368+
if (tmpCont.getResult().isPersisted()) {
369+
resultUrl = tmpCont.getResult().getUrl();
370+
String url = String.valueOf(resultUrl) + ".png";
371+
logger.debug("Downloading result image from: {}", url);
372+
RawType image = HttpUtil.downloadImage(url);
373+
if (image != null) {
374+
resultImage = image;
375+
} else {
376+
resultImage = UnDefType.NULL;
377+
}
374378
} else {
379+
logger.debug("Result image not persisted");
380+
resultUrl = "";
375381
resultImage = UnDefType.NULL;
376382
}
377383

bundles/org.openhab.binding.speedtest/src/main/java/org/openhab/binding/speedtest/internal/dto/ResultContainer.java

+11
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,9 @@ public class Result {
263263
@SerializedName("url")
264264
@Expose
265265
private String url;
266+
@SerializedName("persisted")
267+
@Expose
268+
private boolean persisted;
266269

267270
public String getId() {
268271
return id;
@@ -279,6 +282,14 @@ public String getUrl() {
279282
public void setUrl(String url) {
280283
this.url = url;
281284
}
285+
286+
public boolean isPersisted() {
287+
return persisted;
288+
}
289+
290+
public void setPersisted(boolean persisted) {
291+
this.persisted = persisted;
292+
}
282293
}
283294

284295
public class Server {

0 commit comments

Comments
 (0)