[androidtv] Resolves discovery issues (#16264)

Signed-off-by: Ben Rosenblum <rosenblumb@gmail.com>
Signed-off-by: Ciprian Pascu <contact@ciprianpascu.ro>
This commit is contained in:
morph166955 2024-01-14 10:47:20 -06:00 committed by Ciprian Pascu
parent 543d48a472
commit 27e85c5878
2 changed files with 16 additions and 18 deletions

View 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;
}

View 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;
}