[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 <rosenblumb@gmail.com>
This commit is contained in:
morph166955 2023-07-21 01:54:10 -05:00 committed by GitHub
parent 0beaada48c
commit 16816e3e7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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