From c7816039422f486f21690c2d7a14f70906a371e4 Mon Sep 17 00:00:00 2001 From: pLeminoq Date: Tue, 3 Jan 2017 20:15:37 +0100 Subject: [PATCH] fixed unnecessary updates by the PresenceDetector --- .../openbase/bco/dal/remote/detector/PresenceDetector.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/remote/src/main/java/org/openbase/bco/dal/remote/detector/PresenceDetector.java b/remote/src/main/java/org/openbase/bco/dal/remote/detector/PresenceDetector.java index 245b8b0b..cc1c9004 100644 --- a/remote/src/main/java/org/openbase/bco/dal/remote/detector/PresenceDetector.java +++ b/remote/src/main/java/org/openbase/bco/dal/remote/detector/PresenceDetector.java @@ -74,7 +74,7 @@ public PresenceDetector() { public void expired() { try { // if motion is still detected just restart the timeout. - if(locationDataProvider.getData().getMotionState().getValue() == MotionState.State.MOTION) { + if (locationDataProvider.getData().getMotionState().getValue() == MotionState.State.MOTION) { GlobalCachedExecutorService.submit(new Runnable() { @Override public void run() { @@ -145,9 +145,11 @@ private synchronized void updatePresenceState(final PresenceStateOrBuilder prese presenceTimeout.restart(); this.presenceState.getLastPresenceBuilder().setTime(Math.max(this.presenceState.getLastPresence().getTime(), presenceState.getLastPresence().getTime())); } - // update value + if (!(this.presenceState.getValue() == presenceState.getValue())) { + return; + } this.presenceState.getTimestampBuilder().setTime(System.currentTimeMillis()); this.presenceState.setValue(presenceState.getValue());