mirror of
https://github.com/openhab/openhab-addons.git
synced 2025-01-25 14:55:55 +01:00
[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:
parent
8606f57b56
commit
e439ad68f6
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user