Skip to content

Commit

Permalink
[hue] Fix migration of API v1 legacy data to new v2 things (openhab#1…
Browse files Browse the repository at this point in the history
…6714)

Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
  • Loading branch information
andrewfg authored and matchews committed Oct 18, 2024
1 parent 173fe88 commit 4176c73
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,6 @@ public void execute(String[] args, Console console) {
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ private synchronized void discoverThings() {
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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,13 +366,11 @@ public Optional<Thing> getLegacyThing(String targetIdV1) {
}

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();
}

/**
Expand Down

0 comments on commit 4176c73

Please sign in to comment.