]> git.basschouten.com Git - openhab-addons.git/commitdiff
[touchwand] - remove Thing state update on unit discovery, causing expire to fail...
authorRoie Geron <roie.geron@gmail.com>
Mon, 16 May 2022 14:49:53 +0000 (17:49 +0300)
committerGitHub <noreply@github.com>
Mon, 16 May 2022 14:49:53 +0000 (16:49 +0200)
* remove listeners from unit discovery

Signed-off-by: Roie Geron <roie.geron@gmail.com>
bundles/org.openhab.binding.touchwand/src/main/java/org/openhab/binding/touchwand/internal/discovery/TouchWandUnitDiscoveryService.java

index 5fdd8ee21cec3252b3d28d78866abfb6d6c1bf63..fbb7b302fdd92e138d21918f328f4907ffc9c2db 100644 (file)
@@ -18,7 +18,6 @@ import java.util.Arrays;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
-import java.util.concurrent.CopyOnWriteArraySet;
 import java.util.concurrent.ScheduledFuture;
 import java.util.concurrent.TimeUnit;
 
@@ -26,7 +25,6 @@ import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.NonNullByDefault;
 import org.eclipse.jdt.annotation.Nullable;
 import org.openhab.binding.touchwand.internal.TouchWandBridgeHandler;
-import org.openhab.binding.touchwand.internal.TouchWandUnitStatusUpdateListener;
 import org.openhab.binding.touchwand.internal.dto.TouchWandUnitData;
 import org.openhab.binding.touchwand.internal.dto.TouchWandUnitFromJson;
 import org.openhab.core.config.discovery.AbstractDiscoveryService;
@@ -61,7 +59,6 @@ public class TouchWandUnitDiscoveryService extends AbstractDiscoveryService impl
     private final Logger logger = LoggerFactory.getLogger(TouchWandUnitDiscoveryService.class);
 
     private @Nullable ScheduledFuture<?> scanningJob;
-    private CopyOnWriteArraySet<TouchWandUnitStatusUpdateListener> listeners = new CopyOnWriteArraySet<>();
 
     public TouchWandUnitDiscoveryService() {
         super(SUPPORTED_THING_TYPES_UIDS, SEARCH_TIME_SEC, true);
@@ -123,7 +120,6 @@ public class TouchWandUnitDiscoveryService extends AbstractDiscoveryService impl
                             default:
                                 continue;
                         }
-                        notifyListeners(touchWandUnit);
                     }
                 } catch (JsonSyntaxException e) {
                     logger.warn("Could not parse unit {}", e.getMessage());
@@ -134,12 +130,6 @@ public class TouchWandUnitDiscoveryService extends AbstractDiscoveryService impl
         }
     }
 
-    private void notifyListeners(TouchWandUnitData touchWandUnit) {
-        for (TouchWandUnitStatusUpdateListener listener : listeners) {
-            listener.onDataReceived(touchWandUnit);
-        }
-    }
-
     @Override
     protected void stopScan() {
         removeOlderResults(getTimestampOfLastScan());
@@ -176,18 +166,6 @@ public class TouchWandUnitDiscoveryService extends AbstractDiscoveryService impl
         }
     }
 
-    public void registerListener(TouchWandUnitStatusUpdateListener listener) {
-        if (!listeners.contains(listener)) {
-            logger.debug("Adding TouchWandWebSocket listener {}", listener);
-            listeners.add(listener);
-        }
-    }
-
-    public void unregisterListener(TouchWandUnitStatusUpdateListener listener) {
-        logger.debug("Removing TouchWandWebSocket listener {}", listener);
-        listeners.remove(listener);
-    }
-
     @Override
     public int getScanTimeout() {
         return SEARCH_TIME_SEC;
@@ -215,7 +193,6 @@ public class TouchWandUnitDiscoveryService extends AbstractDiscoveryService impl
     public void setThingHandler(@NonNullByDefault({}) ThingHandler handler) {
         if (handler instanceof TouchWandBridgeHandler) {
             touchWandBridgeHandler = (TouchWandBridgeHandler) handler;
-            registerListener(touchWandBridgeHandler);
         }
     }