[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 IP_ADDRESS = "ipAddress";
|
||||||
public static final String USAGE_INTERVAL = "usageInterval";
|
public static final String USAGE_INTERVAL = "usageInterval";
|
||||||
public static final String STATUS_INTERVAL = "statusInterval";
|
public static final String STATUS_INTERVAL = "statusInterval";
|
||||||
|
public static final String UUID = "uuid";
|
||||||
|
|
||||||
public @Nullable String ipAddress;
|
public @Nullable String ipAddress;
|
||||||
public int usageInterval;
|
public int usageInterval;
|
||||||
public int statusInterval;
|
public int statusInterval;
|
||||||
|
public @Nullable String uuid;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -71,8 +71,9 @@ public class HPPrinterDiscoveryParticipant implements MDNSDiscoveryParticipant {
|
|||||||
String label = service.getName();
|
String label = service.getName();
|
||||||
|
|
||||||
properties.put(HPPrinterConfiguration.IP_ADDRESS, inetAddress);
|
properties.put(HPPrinterConfiguration.IP_ADDRESS, inetAddress);
|
||||||
DiscoveryResult result = DiscoveryResultBuilder.create(uid).withProperties(properties).withLabel(label)
|
properties.put(HPPrinterConfiguration.UUID, service.getPropertyString("UUID"));
|
||||||
.build();
|
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,
|
logger.trace("Created a DiscoveryResult {} for printer on host '{}' name '{}'", result, inetAddress,
|
||||||
label);
|
label);
|
||||||
return result;
|
return result;
|
||||||
|
|||||||
@ -16,6 +16,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.openhab.binding.hpprinter.internal.HPPrinterConfiguration;
|
||||||
import org.openhab.core.thing.Thing;
|
import org.openhab.core.thing.Thing;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
import org.w3c.dom.Element;
|
import org.w3c.dom.Element;
|
||||||
@ -42,6 +43,8 @@ public class HPProperties {
|
|||||||
element.getElementsByTagName("dd:SerialNumber").item(0).getTextContent());
|
element.getElementsByTagName("dd:SerialNumber").item(0).getTextContent());
|
||||||
properties.put(Thing.PROPERTY_MODEL_ID,
|
properties.put(Thing.PROPERTY_MODEL_ID,
|
||||||
element.getElementsByTagName("dd:ProductNumber").item(0).getTextContent());
|
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);
|
Node firmwareDate = element.getElementsByTagName("dd:Version").item(0);
|
||||||
properties.put(Thing.PROPERTY_FIRMWARE_VERSION, firmwareDate.getChildNodes().item(0).getTextContent());
|
properties.put(Thing.PROPERTY_FIRMWARE_VERSION, firmwareDate.getChildNodes().item(0).getTextContent());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,8 +19,9 @@
|
|||||||
</channel-groups>
|
</channel-groups>
|
||||||
<properties>
|
<properties>
|
||||||
<property name="vendor">HP</property>
|
<property name="vendor">HP</property>
|
||||||
|
<property name="uuid"></property>
|
||||||
</properties>
|
</properties>
|
||||||
<representation-property>serialNumber</representation-property>
|
<representation-property>uuid</representation-property>
|
||||||
<config-description-ref uri="thing-type:hpprinter:config"/>
|
<config-description-ref uri="thing-type:hpprinter:config"/>
|
||||||
</thing-type>
|
</thing-type>
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user