Skip to content

Commit 907604f

Browse files
committed
don't add an extra AccessoryInformationService if the accessory already provided one
1 parent 331f75b commit 907604f

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/main/java/io/github/hapjava/server/impl/HomekitRegistry.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,11 @@ public synchronized void reset() {
4242
List<Service> newServices;
4343
try {
4444
newServices = new ArrayList<>(2);
45-
newServices.add(new AccessoryInformationService(accessory));
46-
for (Service service : accessory.getServices()) {
45+
Collection<Service> services = accessory.getServices();
46+
if (!services.stream().anyMatch(s -> s instanceof AccessoryInformationService)) {
47+
newServices.add(new AccessoryInformationService(accessory));
48+
}
49+
for (Service service : services) {
4750
newServices.add(service);
4851
newServices.addAll(service.getLinkedServices());
4952
}

0 commit comments

Comments
 (0)