[km200] Fixed representation-property for discovery result (#9042)

Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
This commit is contained in:
Christoph Weitkamp 2020-11-16 21:34:35 +01:00 committed by GitHub
parent 8aa4be628a
commit 1f4053538f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 11 deletions

View File

@ -41,9 +41,10 @@ import org.slf4j.LoggerFactory;
@Component(configurationPid = "binding.km200") @Component(configurationPid = "binding.km200")
public class KM200GatewayDiscoveryParticipant implements MDNSDiscoveryParticipant { public class KM200GatewayDiscoveryParticipant implements MDNSDiscoveryParticipant {
private final Logger logger = LoggerFactory.getLogger(KM200GatewayDiscoveryParticipant.class); private static final Set<ThingTypeUID> SUPPORTED_ALL_THING_TYPES_UIDS = KM200GatewayHandler.SUPPORTED_THING_TYPES_UIDS;
private static final String IP4_ADDRESS = "ip4Address";
public static final Set<ThingTypeUID> SUPPORTED_ALL_THING_TYPES_UIDS = KM200GatewayHandler.SUPPORTED_THING_TYPES_UIDS; private final Logger logger = LoggerFactory.getLogger(KM200GatewayDiscoveryParticipant.class);
@Override @Override
public Set<ThingTypeUID> getSupportedThingTypeUIDs() { public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
@ -52,17 +53,14 @@ public class KM200GatewayDiscoveryParticipant implements MDNSDiscoveryParticipan
@Override @Override
public @Nullable DiscoveryResult createResult(ServiceInfo info) { public @Nullable DiscoveryResult createResult(ServiceInfo info) {
DiscoveryResult discoveryResult = null;
ThingUID uid = getThingUID(info); ThingUID uid = getThingUID(info);
logger.debug("MDNS info: {}, uid: {}", info, uid); logger.debug("MDNS info: {}, uid: {}", info, uid);
if (uid != null) { if (uid != null) {
InetAddress[] addrs = info.getInetAddresses(); InetAddress[] addrs = info.getInetAddresses();
logger.debug("ip: {} id:{}", addrs[0].getHostAddress(), uid.getId()); logger.debug("ip: {} id:{}", addrs[0].getHostAddress(), uid.getId());
discoveryResult = DiscoveryResultBuilder.create(uid).withProperty("ip4Address", addrs[0].getHostAddress()) return DiscoveryResultBuilder.create(uid).withProperty(IP4_ADDRESS, addrs[0].getHostAddress())
.withProperty("deviceId", uid.getId()).withRepresentationProperty(addrs[0].getHostAddress()) .withProperty("deviceId", uid.getId()).withRepresentationProperty(IP4_ADDRESS)
.withLabel("KM50/100/200 Gateway (" + addrs[0].getHostAddress() + ")").build(); .withLabel("KM50/100/200 Gateway (" + addrs[0].getHostAddress() + ")").build();
return discoveryResult;
} }
return null; return null;
} }
@ -83,8 +81,7 @@ public class KM200GatewayDiscoveryParticipant implements MDNSDiscoveryParticipan
Random rnd = new Random(); Random rnd = new Random();
devId = String.valueOf(rnd.nextLong()); devId = String.valueOf(rnd.nextLong());
} }
ThingUID thinguid = new ThingUID(typeUID, devId); return new ThingUID(typeUID, devId);
return thinguid;
} else { } else {
logger.debug("No uuid property found"); logger.debug("No uuid property found");
} }
@ -102,8 +99,7 @@ public class KM200GatewayDiscoveryParticipant implements MDNSDiscoveryParticipan
private @Nullable ThingTypeUID getThingTypeUID(ServiceInfo info) { private @Nullable ThingTypeUID getThingTypeUID(ServiceInfo info) {
InetAddress[] addrs = info.getInetAddresses(); InetAddress[] addrs = info.getInetAddresses();
if (addrs.length > 0) { if (addrs.length > 0) {
String hardwareID; String hardwareID = info.getPropertyString("hwversion");
hardwareID = info.getPropertyString("hwversion");
logger.debug("hardwareID: {}", hardwareID); logger.debug("hardwareID: {}", hardwareID);
if (hardwareID != null && hardwareID.contains("iCom_Low")) { if (hardwareID != null && hardwareID.contains("iCom_Low")) {
return THING_TYPE_KMDEVICE; return THING_TYPE_KMDEVICE;

View File

@ -9,6 +9,8 @@
<description>The KM200 binding is communicating with a Buderus Logamatic web KM200 / KM100 / KM50. It is possible to <description>The KM200 binding is communicating with a Buderus Logamatic web KM200 / KM100 / KM50. It is possible to
receive and send parameters like string or float values.</description> receive and send parameters like string or float values.</description>
<representation-property>ip4Address</representation-property>
<config-description> <config-description>
<parameter name="ip4Address" type="text" required="true"> <parameter name="ip4Address" type="text" required="true">
<label>IP4 Address</label> <label>IP4 Address</label>