[hue] Fix migration of API v1 legacy data to new v2 things (#16714)

Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
This commit is contained in:
Andrew Fiddian-Green 2024-05-09 09:42:54 +01:00 committed by GitHub
parent 62e62e66a4
commit 1d3c52a33d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 8 deletions

View File

@ -203,7 +203,6 @@ public class HueCommandExtension extends AbstractConsoleCommandExtension impleme
Optional<Thing> legacyThingOptional = clip2BridgeHandler.getLegacyThing(idv1); Optional<Thing> legacyThingOptional = clip2BridgeHandler.getLegacyThing(idv1);
if (legacyThingOptional.isPresent()) { if (legacyThingOptional.isPresent()) {
Thing legacyThing = legacyThingOptional.get(); Thing legacyThing = legacyThingOptional.get();
thingId = legacyThing.getUID().getId();
String legacyLabel = legacyThing.getLabel(); String legacyLabel = legacyThing.getLabel();
thingLabel = Objects.nonNull(legacyLabel) ? legacyLabel : thingLabel; thingLabel = Objects.nonNull(legacyLabel) ? legacyLabel : thingLabel;
} }

View File

@ -121,7 +121,6 @@ public class Clip2ThingDiscoveryService extends AbstractThingHandlerDiscoverySer
if (legacyThingOptional.isPresent()) { if (legacyThingOptional.isPresent()) {
Thing legacyThing = legacyThingOptional.get(); Thing legacyThing = legacyThingOptional.get();
legacyThingUID = legacyThing.getUID().getAsString(); legacyThingUID = legacyThing.getUID().getAsString();
thingId = legacyThing.getUID().getId();
String legacyLabel = legacyThing.getLabel(); String legacyLabel = legacyThing.getLabel();
thingLabel = Objects.nonNull(legacyLabel) ? legacyLabel : thingLabel; thingLabel = Objects.nonNull(legacyLabel) ? legacyLabel : thingLabel;
} }

View File

@ -366,13 +366,11 @@ public class Clip2BridgeHandler extends BaseBridgeHandler {
} }
ThingUID legacyBridgeUID = legacyBridge.get().getUID(); ThingUID legacyBridgeUID = legacyBridge.get().getUID();
return thingRegistry.getAll().stream() // return thingRegistry.getAll().stream()
.filter(thing -> legacyBridgeUID.equals(thing.getBridgeUID()) .filter(thing -> legacyBridgeUID.equals(thing.getBridgeUID())
&& V1_THING_TYPE_UIDS.contains(thing.getThingTypeUID())) // && V1_THING_TYPE_UIDS.contains(thing.getThingTypeUID())
.filter(thing -> { && thing.getConfiguration().get(config) instanceof String id && targetIdV1.endsWith("/" + id))
Object id = thing.getConfiguration().get(config); .findFirst();
return (id instanceof String) && targetIdV1.endsWith("/" + (String) id);
}).findFirst();
} }
/** /**