]> git.basschouten.com Git - openhab-addons.git/commitdiff
[androidtv] Resolves discovery issues (#16264)
authormorph166955 <53797132+morph166955@users.noreply.github.com>
Sun, 14 Jan 2024 16:47:20 +0000 (10:47 -0600)
committerGitHub <noreply@github.com>
Sun, 14 Jan 2024 16:47:20 +0000 (17:47 +0100)
Signed-off-by: Ben Rosenblum <rosenblumb@gmail.com>
bundles/org.openhab.binding.androidtv/src/main/java/org/openhab/binding/androidtv/internal/discovery/GoogleTVDiscoveryParticipant.java
bundles/org.openhab.binding.androidtv/src/main/java/org/openhab/binding/androidtv/internal/discovery/ShieldTVDiscoveryParticipant.java

index eae5b03aa0870e9a631360ec4df65b388fa345ee..ed4c239b27640e3ce2047462df4a8bccb1d75811 100644 (file)
@@ -15,7 +15,6 @@ package org.openhab.binding.androidtv.internal.discovery;
 import static org.openhab.binding.androidtv.internal.AndroidTVBindingConstants.*;
 
 import java.net.InetAddress;
-import java.util.Map;
 import java.util.Set;
 
 import javax.jmdns.ServiceInfo;
@@ -45,7 +44,7 @@ public class GoogleTVDiscoveryParticipant implements MDNSDiscoveryParticipant {
 
     @Override
     public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
-        return SUPPORTED_THING_TYPES;
+        return Set.of(THING_TYPE_GOOGLETV);
     }
 
     @Override
@@ -54,8 +53,8 @@ public class GoogleTVDiscoveryParticipant implements MDNSDiscoveryParticipant {
     }
 
     @Override
-    public @Nullable DiscoveryResult createResult(@Nullable ServiceInfo service) {
-        if ((service == null) || !service.hasData()) {
+    public @Nullable DiscoveryResult createResult(ServiceInfo service) {
+        if (!service.hasData()) {
             return null;
         }
 
@@ -79,9 +78,9 @@ public class GoogleTVDiscoveryParticipant implements MDNSDiscoveryParticipant {
             if (uid != null) {
                 final String id = uid.getId();
                 final String label = service.getName() + " (" + id + ")";
-                final Map<String, Object> properties = Map.of(PARAMETER_IP_ADDRESS, ipAddress);
-
-                return DiscoveryResultBuilder.create(uid).withProperties(properties).withLabel(label).build();
+                return DiscoveryResultBuilder.create(uid).withLabel(label)
+                        .withRepresentationProperty(PARAMETER_IP_ADDRESS).withProperty(PARAMETER_IP_ADDRESS, ipAddress)
+                        .build();
             } else {
                 return null;
             }
@@ -91,8 +90,8 @@ public class GoogleTVDiscoveryParticipant implements MDNSDiscoveryParticipant {
     }
 
     @Override
-    public @Nullable ThingUID getThingUID(@Nullable ServiceInfo service) {
-        if ((service == null) || !service.hasData() || (service.getPropertyString("bt") == null)) {
+    public @Nullable ThingUID getThingUID(ServiceInfo service) {
+        if (!service.hasData() || (service.getPropertyString("bt") == null)) {
             return null;
         }
 
index 428367fbc98deb8c900375eaaaaa075a5155b82c..8a2eaaf2e10eeac21b555c4dd794afd20d75e2ca 100644 (file)
@@ -15,7 +15,6 @@ package org.openhab.binding.androidtv.internal.discovery;
 import static org.openhab.binding.androidtv.internal.AndroidTVBindingConstants.*;
 
 import java.net.InetAddress;
-import java.util.Map;
 import java.util.Set;
 
 import javax.jmdns.ServiceInfo;
@@ -45,7 +44,7 @@ public class ShieldTVDiscoveryParticipant implements MDNSDiscoveryParticipant {
 
     @Override
     public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
-        return SUPPORTED_THING_TYPES;
+        return Set.of(THING_TYPE_SHIELDTV);
     }
 
     @Override
@@ -54,8 +53,8 @@ public class ShieldTVDiscoveryParticipant implements MDNSDiscoveryParticipant {
     }
 
     @Override
-    public @Nullable DiscoveryResult createResult(@Nullable ServiceInfo service) {
-        if (service == null || !service.hasData()) {
+    public @Nullable DiscoveryResult createResult(ServiceInfo service) {
+        if (!service.hasData()) {
             return null;
         }
 
@@ -81,9 +80,9 @@ public class ShieldTVDiscoveryParticipant implements MDNSDiscoveryParticipant {
             if (uid != null) {
                 final String id = uid.getId();
                 final String label = service.getName() + " (" + id + ")";
-                final Map<String, Object> properties = Map.of(PARAMETER_IP_ADDRESS, ipAddress);
-
-                return DiscoveryResultBuilder.create(uid).withProperties(properties).withLabel(label).build();
+                return DiscoveryResultBuilder.create(uid).withLabel(label)
+                        .withRepresentationProperty(PARAMETER_IP_ADDRESS).withProperty(PARAMETER_IP_ADDRESS, ipAddress)
+                        .build();
             } else {
                 return null;
             }
@@ -93,8 +92,8 @@ public class ShieldTVDiscoveryParticipant implements MDNSDiscoveryParticipant {
     }
 
     @Override
-    public @Nullable ThingUID getThingUID(@Nullable ServiceInfo service) {
-        if (service == null || !service.hasData() || (service.getPropertyString("SERVER") == null)) {
+    public @Nullable ThingUID getThingUID(ServiceInfo service) {
+        if (!service.hasData() || (service.getPropertyString("SERVER") == null)) {
             return null;
         }