Java Code Examples for org.eclipse.smarthome.config.discovery.DiscoveryResult#getThingUID()
The following examples show how to use
org.eclipse.smarthome.config.discovery.DiscoveryResult#getThingUID() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InboxConsoleCommandExtension.java From smarthome with Eclipse Public License 2.0 | 6 votes |
private void printInboxEntries(Console console, List<DiscoveryResult> discoveryResults) { if (discoveryResults.isEmpty()) { console.println("No inbox entries found."); } for (DiscoveryResult discoveryResult : discoveryResults) { ThingTypeUID thingTypeUID = discoveryResult.getThingTypeUID(); ThingUID thingUID = discoveryResult.getThingUID(); String label = discoveryResult.getLabel(); DiscoveryResultFlag flag = discoveryResult.getFlag(); ThingUID bridgeId = discoveryResult.getBridgeUID(); Map<String, Object> properties = discoveryResult.getProperties(); String representationProperty = discoveryResult.getRepresentationProperty(); String timestamp = new Date(discoveryResult.getTimestamp()).toString(); String timeToLive = discoveryResult.getTimeToLive() == DiscoveryResult.TTL_UNLIMITED ? "UNLIMITED" : "" + discoveryResult.getTimeToLive(); console.println(String.format( "%s [%s]: %s [thingId=%s, bridgeId=%s, properties=%s, representationProperty=%s, timestamp=%s, timeToLive=%s]", flag.name(), thingTypeUID, label, thingUID, bridgeId, properties, representationProperty, timestamp, timeToLive)); } }
Example 2
Source File: InboxConsoleCommandExtension.java From smarthome with Eclipse Public License 2.0 | 6 votes |
private void clearInboxEntries(Console console, List<DiscoveryResult> discoveryResults) { if (discoveryResults.isEmpty()) { console.println("No inbox entries found."); } for (DiscoveryResult discoveryResult : discoveryResults) { ThingTypeUID thingTypeUID = discoveryResult.getThingTypeUID(); ThingUID thingUID = discoveryResult.getThingUID(); String label = discoveryResult.getLabel(); DiscoveryResultFlag flag = discoveryResult.getFlag(); ThingUID bridgeId = discoveryResult.getBridgeUID(); Map<String, Object> properties = discoveryResult.getProperties(); console.println(String.format("REMOVED [%s]: %s [label=%s, thingId=%s, bridgeId=%s, properties=%s]", flag.name(), thingTypeUID, label, thingUID, bridgeId, properties)); inbox.remove(thingUID); } }
Example 3
Source File: PersistentInbox.java From smarthome with Eclipse Public License 2.0 | 6 votes |
@Override public @Nullable Collection<ThingUID> removeOlderResults(DiscoveryService source, long timestamp, @Nullable Collection<ThingTypeUID> thingTypeUIDs, @Nullable ThingUID bridgeUID) { HashSet<ThingUID> removedThings = new HashSet<>(); for (DiscoveryResult discoveryResult : getAll()) { Class<?> discoverer = resultDiscovererMap.get(discoveryResult); if (thingTypeUIDs != null && thingTypeUIDs.contains(discoveryResult.getThingTypeUID()) && discoveryResult.getTimestamp() < timestamp && (discoverer == null || source.getClass() == discoverer)) { ThingUID thingUID = discoveryResult.getThingUID(); if (bridgeUID == null || bridgeUID.equals(discoveryResult.getBridgeUID())) { removedThings.add(thingUID); remove(thingUID); logger.debug("Removed {} from inbox because it was older than {}", thingUID, new Date(timestamp)); } } } return removedThings; }
Example 4
Source File: DiscoveryResultDTOMapper.java From smarthome with Eclipse Public License 2.0 | 5 votes |
/** * Maps discovery result into discovery result data transfer object. * * @param discoveryResult the discovery result * @return the discovery result data transfer object */ public static DiscoveryResultDTO map(DiscoveryResult discoveryResult) { ThingUID thingUID = discoveryResult.getThingUID(); ThingUID bridgeUID = discoveryResult.getBridgeUID(); return new DiscoveryResultDTO(thingUID.toString(), bridgeUID != null ? bridgeUID.toString() : null, discoveryResult.getThingTypeUID().toString(), discoveryResult.getLabel(), discoveryResult.getFlag(), discoveryResult.getProperties(), discoveryResult.getRepresentationProperty()); }