From 16816e3e7a355aa0640c60d21c3d39e8a43cae80 Mon Sep 17 00:00:00 2001 From: morph166955 <53797132+morph166955@users.noreply.github.com> Date: Fri, 21 Jul 2023 01:54:10 -0500 Subject: [PATCH] [androidtv] Fix log flood when physical device is not online (#15258) * Fixes log flood when physical device is not online --------- Signed-off-by: Ben Rosenblum --- .../androidtv/internal/AndroidTVHandler.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/bundles/org.openhab.binding.androidtv/src/main/java/org/openhab/binding/androidtv/internal/AndroidTVHandler.java b/bundles/org.openhab.binding.androidtv/src/main/java/org/openhab/binding/androidtv/internal/AndroidTVHandler.java index 6904d8b21c1..851b29393f7 100644 --- a/bundles/org.openhab.binding.androidtv/src/main/java/org/openhab/binding/androidtv/internal/AndroidTVHandler.java +++ b/bundles/org.openhab.binding.androidtv/src/main/java/org/openhab/binding/androidtv/internal/AndroidTVHandler.java @@ -65,6 +65,9 @@ public class AndroidTVHandler extends BaseThingHandler { private final ThingTypeUID thingTypeUID; private final String thingID; + private String currentThingStatus = ""; + private boolean currentThingFailed = false; + public AndroidTVHandler(Thing thing, AndroidTVDynamicCommandDescriptionProvider commandDescriptionProvider, AndroidTVTranslationProvider translationProvider, ThingTypeUID thingTypeUID) { super(thing); @@ -111,6 +114,9 @@ public class AndroidTVHandler extends BaseThingHandler { } public void checkThingStatus() { + String currentThingStatus = this.currentThingStatus; + boolean currentThingFailed = this.currentThingFailed; + String statusMessage = ""; boolean failed = false; @@ -133,11 +139,16 @@ public class AndroidTVHandler extends BaseThingHandler { } } - if (failed) { - updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, statusMessage); - } else { - updateStatus(ThingStatus.ONLINE); + if (!currentThingStatus.equals(statusMessage) || (currentThingFailed != failed)) { + if (failed) { + updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.NONE, statusMessage); + } else { + updateStatus(ThingStatus.ONLINE); + } } + + this.currentThingStatus = statusMessage; + this.currentThingFailed = failed; } @Override