UPNP don't notify embedded child devices by default (#4735)

Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
pull/4835/head
Andrew Fiddian-Green 2025-05-29 10:02:00 +02:00 committed by GitHub
parent 5b12280f5b
commit cce185af64
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 0 deletions

View File

@ -79,4 +79,14 @@ public interface UpnpDiscoveryParticipant {
default long getRemovalGracePeriodSeconds(RemoteDevice device) {
return 0;
}
/**
* The discovery always notifies participants about discovered root devices. And if the participant also
* wants to be notified about embedded child devices then it shall override this method.
*
* @return true if the participant wants to be also notified about embedded child devices.
*/
default boolean notifyChildDevices() {
return false;
}
}

View File

@ -113,6 +113,9 @@ public class UpnpDiscoveryService extends AbstractDiscoveryService
Collection<RemoteDevice> devices = upnpService.getRegistry().getRemoteDevices();
for (RemoteDevice device : devices) {
if (!device.isRoot() && !participant.notifyChildDevices()) {
continue;
}
DiscoveryResult result = participant.createResult(device);
if (result != null) {
final DiscoveryResult resultNew = getLocalizedDiscoveryResult(result,
@ -171,6 +174,9 @@ public class UpnpDiscoveryService extends AbstractDiscoveryService
@Override
public void remoteDeviceAdded(Registry registry, RemoteDevice device) {
for (UpnpDiscoveryParticipant participant : participants) {
if (!device.isRoot() && !participant.notifyChildDevices()) {
continue;
}
try {
DiscoveryResult result = participant.createResult(device);
if (result != null) {
@ -200,6 +206,9 @@ public class UpnpDiscoveryService extends AbstractDiscoveryService
@Override
public void remoteDeviceRemoved(Registry registry, RemoteDevice device) {
for (UpnpDiscoveryParticipant participant : participants) {
if (!device.isRoot() && !participant.notifyChildDevices()) {
continue;
}
try {
ThingUID thingUID = participant.getThingUID(device);
if (thingUID != null) {