]> git.basschouten.com Git - openhab-addons.git/commitdiff
[openwebnet] Fixes #8524 and #8547, updated openwebnet4j lib to 0.3.1. Updated README...
authorM Valla <12682715+mvalla@users.noreply.github.com>
Mon, 5 Oct 2020 15:50:38 +0000 (17:50 +0200)
committerGitHub <noreply@github.com>
Mon, 5 Oct 2020 15:50:38 +0000 (17:50 +0200)
Signed-off-by: Massimo Valla <mvcode00@gmail.com>
bundles/org.openhab.binding.openwebnet/README.md
bundles/org.openhab.binding.openwebnet/pom.xml
bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/handler/OpenWebNetBridgeHandler.java
bundles/org.openhab.binding.openwebnet/src/main/java/org/openhab/binding/openwebnet/internal/discovery/OpenWebNetDeviceDiscoveryService.java

index bac537abb0c1b1d27f0d7773acb435b76e402831..32c56977c2398f70b603e9b2a42c7c50cc5dd93a 100644 (file)
@@ -66,7 +66,7 @@ For other gateways you can add them manually, see [Thing Configuration](#thing-c
 
 Devices can also be discovered if activated while an Inbox Scan is active: start a new Scan, wait 15-20 seconds and then _while the Scan is still active_ (spinning arrow in Inbox), activate the physical device (for example dim the dimmer) to have it discovered by the binding.
 
-If a device cannot be discovered automatically it's always possible to add them manually, see [Configuring Devices](#configuring-devices).
+If a device cannot be discovered automatically it's always possible to add it manually, see [Configuring Devices](#configuring-devices).
 
 ### ZigBee Discovery
 
@@ -210,5 +210,6 @@ Special thanks for helping on testing this binding go to:
 [@k0nti](https://community.openhab.org/u/k0nti/),
 [@gilberto.cocchi](https://community.openhab.org/u/gilberto.cocchi/),
 [@llegovich](https://community.openhab.org/u/llegovich),
-[@gabriele.daltoe](https://community.openhab.org/u/gabriele.daltoe)
+[@gabriele.daltoe](https://community.openhab.org/u/gabriele.daltoe),
+[@feodor](https://community.openhab.org/u/feodor)
 and many others at the fantastic openHAB community!
index dfb16029d68253d99f024e75c8d0294efdaa9853..a779114839d846844cf24fe87c010f5415645922 100644 (file)
@@ -23,7 +23,7 @@
     <dependency>
       <groupId>com.github.openwebnet4j</groupId>
       <artifactId>openwebnet4j</artifactId>
-      <version>0.3.0</version>
+      <version>0.3.1</version>
       <scope>compile</scope>
     </dependency>
 
index b917aca2ae8618a9e83e8fa56f4178b805a65326..451ad9473ce4078037bd2a7855e807d452018f1b 100644 (file)
@@ -314,16 +314,26 @@ public class OpenWebNetBridgeHandler extends ConfigStatusBridgeHandler implement
     /**
      * Un-register a device from this bridge handler
      *
-     * @param oId the device OpenWebNet id
+     * @param ownId the device OpenWebNet id
      */
-    protected void unregisterDevice(String oId) {
-        if (registeredDevices.remove(oId) != null) {
-            logger.debug("un-registered device ownId={}", oId);
+    protected void unregisterDevice(String ownId) {
+        if (registeredDevices.remove(ownId) != null) {
+            logger.debug("un-registered device ownId={}", ownId);
         } else {
-            logger.warn("could not un-register ownId={} (not found)", oId);
+            logger.warn("could not un-register ownId={} (not found)", ownId);
         }
     }
 
+    /**
+     * Get an already registered device on this bridge handler
+     *
+     * @param ownId the device OpenWebNet id
+     * @return the registered device Thing handler or null if the id cannot be found
+     */
+    public @Nullable OpenWebNetThingHandler getRegisteredDevice(String ownId) {
+        return registeredDevices.get(ownId);
+    }
+
     @Override
     public void onEventMessage(@Nullable OpenMessage msg) {
         logger.trace("RECEIVED <<<<< {}", msg);
index 60bb8535042cd1d64b1a418ef4b25ed862f5f84a..3668722bdaef130451d6a3d5ea047ace5eabcb12 100644 (file)
@@ -138,6 +138,15 @@ public class OpenWebNetDeviceDiscoveryService extends AbstractDiscoveryService
                     deviceWho = baseMsg.getWho();
                 }
         }
+
+        String ownId = bridgeHandler.ownIdFromWhoWhere(where, deviceWho);
+        if (thingTypeUID == OpenWebNetBindingConstants.THING_TYPE_BUS_ON_OFF_SWITCH) {
+            if (bridgeHandler.getRegisteredDevice(ownId) != null) {
+                logger.debug("dimmer/switch with WHERE={} already registered, skipping this discovery result", where);
+                return;
+            }
+        }
+
         String tId = bridgeHandler.thingIdFromWhere(where);
         ThingUID thingUID = new ThingUID(thingTypeUID, bridgeUID, tId);
 
@@ -159,7 +168,7 @@ public class OpenWebNetDeviceDiscoveryService extends AbstractDiscoveryService
         }
         Map<String, Object> properties = new HashMap<>(2);
         properties.put(OpenWebNetBindingConstants.CONFIG_PROPERTY_WHERE, bridgeHandler.normalizeWhere(where));
-        properties.put(OpenWebNetBindingConstants.PROPERTY_OWNID, bridgeHandler.ownIdFromWhoWhere(where, deviceWho));
+        properties.put(OpenWebNetBindingConstants.PROPERTY_OWNID, ownId);
         if (thingTypeUID == OpenWebNetBindingConstants.THING_TYPE_GENERIC_DEVICE) {
             thingLabel = thingLabel + " (WHO=" + deviceWho + ", WHERE=" + whereLabel + ")";
         } else {