From f63836a61128ff243709e3a6b41a84c4a21e421f Mon Sep 17 00:00:00 2001 From: Karel Goderis Date: Sun, 11 Jun 2017 20:57:37 +0200 Subject: [PATCH] Tesla : reset the Even Stream connection to the Tesla Back-end if the event time stamps differ too much from the current system time (#2358) Signed-off-by: Karel Goderis --- .../org/openhab/binding/tesla/handler/TeslaHandler.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/addons/binding/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/handler/TeslaHandler.java b/addons/binding/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/handler/TeslaHandler.java index a40cda3d86e46..a7f2dddfd7462 100644 --- a/addons/binding/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/handler/TeslaHandler.java +++ b/addons/binding/org.openhab.binding.tesla/src/main/java/org/openhab/binding/tesla/handler/TeslaHandler.java @@ -91,6 +91,7 @@ public class TeslaHandler extends BaseThingHandler { private static final int EVENT_STREAM_CONNECT_TIMEOUT = 3000; private static final int EVENT_STREAM_READ_TIMEOUT = 200000; private static final int EVENT_TIMESTAMP_AGE_LIMIT = 3000; + private static final int EVENT_TIMESTAMP_MAX_DELTA = 10000; private static final int FAST_STATUS_REFRESH_INTERVAL = 15000; private static final int SLOW_STATUS_REFRESH_INTERVAL = 60000; private static final int CONNECT_RETRY_INTERVAL = 15000; @@ -1040,6 +1041,12 @@ public void run() { dateFormatter.format(currentTimeStamp), dateFormatter.format(systemTimeStamp)); } + if (systemTimeStamp - currentTimeStamp > EVENT_TIMESTAMP_MAX_DELTA) { + if (logger.isTraceEnabled()) { + logger.trace("Event Stream : The event stream will be reset"); + } + isEstablished = false; + } } line = eventBufferedReader.readLine();