]> git.basschouten.com Git - openhab-addons.git/commitdiff
[hue] Fix migration of API v1 legacy data to new v2 things (#16714)
authorAndrew Fiddian-Green <software@whitebear.ch>
Thu, 9 May 2024 08:42:54 +0000 (09:42 +0100)
committerGitHub <noreply@github.com>
Thu, 9 May 2024 08:42:54 +0000 (10:42 +0200)
Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/console/HueCommandExtension.java
bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/discovery/Clip2ThingDiscoveryService.java
bundles/org.openhab.binding.hue/src/main/java/org/openhab/binding/hue/internal/handler/Clip2BridgeHandler.java

index 5d13c84ef4d563fe25ce484d17e604ae3b169438..2ac6a1240c9c5b726aa4e90f251d3edf8120d7ae 100644 (file)
@@ -203,7 +203,6 @@ public class HueCommandExtension extends AbstractConsoleCommandExtension impleme
                                         Optional<Thing> legacyThingOptional = clip2BridgeHandler.getLegacyThing(idv1);
                                         if (legacyThingOptional.isPresent()) {
                                             Thing legacyThing = legacyThingOptional.get();
-                                            thingId = legacyThing.getUID().getId();
                                             String legacyLabel = legacyThing.getLabel();
                                             thingLabel = Objects.nonNull(legacyLabel) ? legacyLabel : thingLabel;
                                         }
index 63b014b0f731a90ff396a0f48782725879424601..6baced87b1f50b2a0c9d70979eb50b522f996ba4 100644 (file)
@@ -121,7 +121,6 @@ public class Clip2ThingDiscoveryService extends AbstractThingHandlerDiscoverySer
                         if (legacyThingOptional.isPresent()) {
                             Thing legacyThing = legacyThingOptional.get();
                             legacyThingUID = legacyThing.getUID().getAsString();
-                            thingId = legacyThing.getUID().getId();
                             String legacyLabel = legacyThing.getLabel();
                             thingLabel = Objects.nonNull(legacyLabel) ? legacyLabel : thingLabel;
                         }
index ec2ce89203b3374422465cc677fc1dafb42c47b0..3fdeeab9feb50c1868a04a06bdd94142e59721d8 100644 (file)
@@ -366,13 +366,11 @@ public class Clip2BridgeHandler extends BaseBridgeHandler {
         }
 
         ThingUID legacyBridgeUID = legacyBridge.get().getUID();
-        return thingRegistry.getAll().stream() //
+        return thingRegistry.getAll().stream()
                 .filter(thing -> legacyBridgeUID.equals(thing.getBridgeUID())
-                        && V1_THING_TYPE_UIDS.contains(thing.getThingTypeUID())) //
-                .filter(thing -> {
-                    Object id = thing.getConfiguration().get(config);
-                    return (id instanceof String) && targetIdV1.endsWith("/" + (String) id);
-                }).findFirst();
+                        && V1_THING_TYPE_UIDS.contains(thing.getThingTypeUID())
+                        && thing.getConfiguration().get(config) instanceof String id && targetIdV1.endsWith("/" + id))
+                .findFirst();
     }
 
     /**