[hpprinter] implement uuid as repr. prop. to stop discovery duplicates (#8810)

Signed-off-by: Andrew Fiddian-Green <software@whitebear.ch>
This commit is contained in:
Andrew Fiddian-Green 2020-10-22 18:19:01 +01:00 committed by GitHub
parent 8606f57b56
commit e439ad68f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 3 deletions

View File

@ -25,8 +25,10 @@ public class HPPrinterConfiguration {
public static final String IP_ADDRESS = "ipAddress";
public static final String USAGE_INTERVAL = "usageInterval";
public static final String STATUS_INTERVAL = "statusInterval";
public static final String UUID = "uuid";
public @Nullable String ipAddress;
public int usageInterval;
public int statusInterval;
public @Nullable String uuid;
}

View File

@ -71,8 +71,9 @@ public class HPPrinterDiscoveryParticipant implements MDNSDiscoveryParticipant {
String label = service.getName();
properties.put(HPPrinterConfiguration.IP_ADDRESS, inetAddress);
DiscoveryResult result = DiscoveryResultBuilder.create(uid).withProperties(properties).withLabel(label)
.build();
properties.put(HPPrinterConfiguration.UUID, service.getPropertyString("UUID"));
DiscoveryResult result = DiscoveryResultBuilder.create(uid).withProperties(properties)
.withRepresentationProperty(HPPrinterConfiguration.UUID).withLabel(label).build();
logger.trace("Created a DiscoveryResult {} for printer on host '{}' name '{}'", result, inetAddress,
label);
return result;

View File

@ -16,6 +16,7 @@ import java.util.HashMap;
import java.util.Map;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.hpprinter.internal.HPPrinterConfiguration;
import org.openhab.core.thing.Thing;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@ -42,6 +43,8 @@ public class HPProperties {
element.getElementsByTagName("dd:SerialNumber").item(0).getTextContent());
properties.put(Thing.PROPERTY_MODEL_ID,
element.getElementsByTagName("dd:ProductNumber").item(0).getTextContent());
properties.put(HPPrinterConfiguration.UUID,
element.getElementsByTagName("dd:UUID").item(0).getTextContent());
Node firmwareDate = element.getElementsByTagName("dd:Version").item(0);
properties.put(Thing.PROPERTY_FIRMWARE_VERSION, firmwareDate.getChildNodes().item(0).getTextContent());
}

View File

@ -19,8 +19,9 @@
</channel-groups>
<properties>
<property name="vendor">HP</property>
<property name="uuid"></property>
</properties>
<representation-property>serialNumber</representation-property>
<representation-property>uuid</representation-property>
<config-description-ref uri="thing-type:hpprinter:config"/>
</thing-type>