From 8fcf18fc28a3a1e28bd54e7a8edf766b078acd49 Mon Sep 17 00:00:00 2001 From: mlobstein Date: Sat, 5 Oct 2024 03:54:41 -0500 Subject: [PATCH] switch to SDDP discovery (#17508) Signed-off-by: Michael Lobstein --- .../README.md | 2 +- .../src/main/feature/feature.xml | 2 +- .../KaleidescapeDiscoveryParticipant.java | 39 +++++++------------ .../src/main/resources/OH-INF/addon/addon.xml | 8 +--- 4 files changed, 18 insertions(+), 33 deletions(-) diff --git a/bundles/org.openhab.binding.kaleidescape/README.md b/bundles/org.openhab.binding.kaleidescape/README.md index b67fc42d4e..9921a78179 100644 --- a/bundles/org.openhab.binding.kaleidescape/README.md +++ b/bundles/org.openhab.binding.kaleidescape/README.md @@ -22,7 +22,7 @@ The binding supports either a TCP/IP connection or direct serial port connection ## Discovery -Auto-discovery is supported for Alto and Strato components if the device can be located on the local network using UPnP. +Auto-discovery is supported for Alto and Strato components if the device can be located on the local network using SDDP. Manually initiated discovery will locate all legacy Premiere line components if they are on the same IP subnet of the openHAB server. In the Inbox, select Search For Things and then choose the Kaleidescape Binding to initiate a discovery scan. diff --git a/bundles/org.openhab.binding.kaleidescape/src/main/feature/feature.xml b/bundles/org.openhab.binding.kaleidescape/src/main/feature/feature.xml index cfe4e85e0b..0dee2c017b 100644 --- a/bundles/org.openhab.binding.kaleidescape/src/main/feature/feature.xml +++ b/bundles/org.openhab.binding.kaleidescape/src/main/feature/feature.xml @@ -5,7 +5,7 @@ openhab-runtime-base openhab-transport-serial - openhab-transport-upnp + openhab-core-config-discovery-sddp mvn:org.openhab.addons.bundles/org.openhab.binding.kaleidescape/${project.version} diff --git a/bundles/org.openhab.binding.kaleidescape/src/main/java/org/openhab/binding/kaleidescape/internal/discovery/KaleidescapeDiscoveryParticipant.java b/bundles/org.openhab.binding.kaleidescape/src/main/java/org/openhab/binding/kaleidescape/internal/discovery/KaleidescapeDiscoveryParticipant.java index ef1d0d45fa..d5a76a0cfd 100644 --- a/bundles/org.openhab.binding.kaleidescape/src/main/java/org/openhab/binding/kaleidescape/internal/discovery/KaleidescapeDiscoveryParticipant.java +++ b/bundles/org.openhab.binding.kaleidescape/src/main/java/org/openhab/binding/kaleidescape/internal/discovery/KaleidescapeDiscoveryParticipant.java @@ -20,10 +20,10 @@ import java.util.Set; import org.eclipse.jdt.annotation.NonNullByDefault; import org.eclipse.jdt.annotation.Nullable; -import org.jupnp.model.meta.RemoteDevice; import org.openhab.core.config.discovery.DiscoveryResult; import org.openhab.core.config.discovery.DiscoveryResultBuilder; -import org.openhab.core.config.discovery.upnp.UpnpDiscoveryParticipant; +import org.openhab.core.config.discovery.sddp.SddpDevice; +import org.openhab.core.config.discovery.sddp.SddpDiscoveryParticipant; import org.openhab.core.thing.ThingTypeUID; import org.openhab.core.thing.ThingUID; import org.osgi.service.component.annotations.Component; @@ -31,14 +31,14 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** - * The {@link KaleidescapeDiscoveryParticipant} class discovers Strato/Encore line components automatically via UPnP. + * The {@link KaleidescapeDiscoveryParticipant} class discovers Strato/Encore line components automatically via SDDP. * * @author Michael Lobstein - Initial contribution * */ @NonNullByDefault @Component(immediate = true) -public class KaleidescapeDiscoveryParticipant implements UpnpDiscoveryParticipant { +public class KaleidescapeDiscoveryParticipant implements SddpDiscoveryParticipant { private final Logger logger = LoggerFactory.getLogger(KaleidescapeDiscoveryParticipant.class); private static final String MANUFACTURER = "Kaleidescape"; @@ -53,26 +53,19 @@ public class KaleidescapeDiscoveryParticipant implements UpnpDiscoveryParticipan } @Override - public @Nullable DiscoveryResult createResult(RemoteDevice device) { + public @Nullable DiscoveryResult createResult(SddpDevice device) { final ThingUID uid = getThingUID(device); if (uid != null) { final Map properties = new HashMap<>(3); - final String label; - - if (device.getDetails().getFriendlyName() != null && !device.getDetails().getFriendlyName().isBlank()) { - label = device.getDetails().getFriendlyName(); - } else { - label = device.getDetails().getModelDetails().getModelName(); - } properties.put(PROPERTY_UUID, uid.getId()); - properties.put(PROPERTY_HOST_NAME, device.getIdentity().getDescriptorURL().getHost()); + properties.put(PROPERTY_HOST_NAME, device.ipAddress); properties.put(PROPERTY_PORT_NUM, DEFAULT_API_PORT); final DiscoveryResult result = DiscoveryResultBuilder.create(uid).withProperties(properties) - .withRepresentationProperty(PROPERTY_UUID).withLabel(label).build(); + .withRepresentationProperty(PROPERTY_UUID).withLabel(device.model).build(); - logger.debug("Created a DiscoveryResult for device '{}' with UID '{}'", label, uid.getId()); + logger.debug("Created a DiscoveryResult for device '{}' with UID '{}'", device.model, uid.getId()); return result; } else { return null; @@ -80,24 +73,20 @@ public class KaleidescapeDiscoveryParticipant implements UpnpDiscoveryParticipan } @Override - public @Nullable ThingUID getThingUID(RemoteDevice device) { - if (device.getDetails().getManufacturerDetails().getManufacturer() != null - && device.getDetails().getModelDetails().getModelName() != null - && device.getDetails().getManufacturerDetails().getManufacturer().startsWith(MANUFACTURER)) { - final String modelName = device.getDetails().getModelDetails().getModelName(); - final String id = device.getIdentity().getUdn().getIdentifierString().replace(":", EMPTY); + public @Nullable ThingUID getThingUID(SddpDevice device) { + if (device.manufacturer.startsWith(MANUFACTURER)) { + final String id = device.macAddress; - logger.debug("Kaleidescape {} with id {} found at {}", modelName, id, - device.getIdentity().getDescriptorURL().getHost()); + logger.debug("Kaleidescape {} with id {} found at {}", device.model, id, device.host); if (id.isBlank()) { logger.debug("Invalid UDN for Kaleidescape device: {}", device.toString()); return null; } - if (modelName.contains(ALTO)) { + if (device.model.contains(ALTO)) { return new ThingUID(THING_TYPE_ALTO, id); - } else if (modelName.contains(STRATO)) { + } else if (device.model.contains(STRATO)) { return new ThingUID(THING_TYPE_STRATO, id); } } diff --git a/bundles/org.openhab.binding.kaleidescape/src/main/resources/OH-INF/addon/addon.xml b/bundles/org.openhab.binding.kaleidescape/src/main/resources/OH-INF/addon/addon.xml index 6bf41b4363..cd8b2ce4f8 100644 --- a/bundles/org.openhab.binding.kaleidescape/src/main/resources/OH-INF/addon/addon.xml +++ b/bundles/org.openhab.binding.kaleidescape/src/main/resources/OH-INF/addon/addon.xml @@ -10,15 +10,11 @@ - upnp + sddp manufacturer - (?i)Kaleidescape - - - deviceType - .*Basic.* + (?i).*kaleidescape.* -- 2.47.3