Skip to content

Commit

Permalink
Added representation-property to thing type definitions (openhab#11640)
Browse files Browse the repository at this point in the history
Signed-off-by: Christoph Weitkamp <github@christophweitkamp.de>
  • Loading branch information
cweitkamp authored Nov 26, 2021
1 parent 57cc877 commit 0fca738
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import static org.openhab.core.thing.Thing.PROPERTY_VENDOR;

import java.util.Dictionary;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;

Expand All @@ -28,6 +27,7 @@
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.upnp.internal.UpnpDiscoveryService;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.ThingUID;
import org.osgi.service.component.ComponentContext;
Expand Down Expand Up @@ -83,16 +83,11 @@ public Set<ThingTypeUID> getSupportedThingTypeUIDs() {
if (uid != null) {
logger.debug("discovered: {} ({}) at {}", device.getDisplayString(),
device.getDetails().getFriendlyName(), device.getIdentity().getDescriptorURL().getHost());

Map<String, Object> properties = new HashMap<>();
properties.put(CONFIG_IP_ADDRESS, device.getIdentity().getDescriptorURL().getHost());
properties.put(PROPERTY_VENDOR, device.getDetails().getManufacturerDetails().getManufacturer());

DiscoveryResult result = DiscoveryResultBuilder.create(uid).withProperties(properties)
return DiscoveryResultBuilder.create(uid)
.withProperties(Map.of(CONFIG_IP_ADDRESS, device.getIdentity().getDescriptorURL().getHost(),
PROPERTY_VENDOR, device.getDetails().getManufacturerDetails().getManufacturer()))
.withLabel(device.getDetails().getFriendlyName()).withRepresentationProperty(CONFIG_IP_ADDRESS)
.build();

return result;
}
}
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
<channel id="apply_template" typeId="apply_template"/>
</channels>

<representation-property>ipAddress</representation-property>

<config-description-ref uri="bridge-type:avmfritz:fritzbox"/>
</bridge-type>

Expand All @@ -34,6 +36,8 @@
<channel id="outlet" typeId="outlet"/>
</channels>

<representation-property>ipAddress</representation-property>

<config-description-ref uri="bridge-type:avmfritz:fritzpowerline"/>
</bridge-type>
</thing:thing-descriptions>

0 comments on commit 0fca738

Please sign in to comment.