use of org.eclipse.smarthome.core.thing.ThingTypeUID in project smarthome by eclipse.
the class DiscoveryServiceRegistryImpl method abortScans.
private boolean abortScans(Set<DiscoveryService> discoveryServices) {
boolean allServicesAborted = true;
for (DiscoveryService discoveryService : discoveryServices) {
Collection<ThingTypeUID> supportedThingTypes = discoveryService.getSupportedThingTypes();
try {
logger.debug("Abort scan for thing types '{}' on '{}'...", supportedThingTypes, discoveryService.getClass().getName());
discoveryService.abortScan();
logger.debug("Scan for thing types '{}' aborted on '{}'.", supportedThingTypes, discoveryService.getClass().getName());
} catch (Exception ex) {
logger.error("Cannot abort scan for thing types '{}' on '{}'!", supportedThingTypes, discoveryService.getClass().getName(), ex);
allServicesAborted = false;
}
}
return allServicesAborted;
}
use of org.eclipse.smarthome.core.thing.ThingTypeUID in project smarthome by eclipse.
the class PersistentInbox method matchFilter.
private boolean matchFilter(DiscoveryResult discoveryResult, InboxFilterCriteria criteria) {
if (criteria != null) {
String bindingId = criteria.getBindingId();
if ((bindingId != null) && (!bindingId.isEmpty())) {
if (!discoveryResult.getBindingId().equals(bindingId)) {
return false;
}
}
ThingTypeUID thingTypeUID = criteria.getThingTypeUID();
if (thingTypeUID != null) {
if (!discoveryResult.getThingTypeUID().equals(thingTypeUID)) {
return false;
}
}
ThingUID thingUID = criteria.getThingUID();
if (thingUID != null) {
if (!discoveryResult.getThingUID().equals(thingUID)) {
return false;
}
}
DiscoveryResultFlag flag = criteria.getFlag();
if (flag != null) {
if (discoveryResult.getFlag() != flag) {
return false;
}
}
}
return true;
}
use of org.eclipse.smarthome.core.thing.ThingTypeUID in project smarthome by eclipse.
the class PersistentInbox method approve.
@Override
public Thing approve(ThingUID thingUID, String label) {
if (thingUID == null) {
throw new IllegalArgumentException("Thing UID must not be null");
}
List<DiscoveryResult> results = stream().filter(forThingUID(thingUID)).collect(Collectors.toList());
if (results.isEmpty()) {
throw new IllegalArgumentException("No Thing with UID " + thingUID.getAsString() + " in inbox");
}
DiscoveryResult result = results.get(0);
final Map<String, String> properties = new HashMap<>();
final Map<String, Object> configParams = new HashMap<>();
getPropsAndConfigParams(result, properties, configParams);
final Configuration config = new Configuration(configParams);
ThingTypeUID thingTypeUID = result.getThingTypeUID();
Thing newThing = ThingFactory.createThing(thingUID, config, properties, result.getBridgeUID(), thingTypeUID, this.thingHandlerFactories);
if (newThing == null) {
logger.warn("Cannot create thing. No binding found that supports creating a thing" + " of type {}.", thingTypeUID);
return null;
}
if (label != null && !label.isEmpty()) {
newThing.setLabel(label);
} else {
newThing.setLabel(result.getLabel());
}
addThingSafely(newThing);
return newThing;
}
use of org.eclipse.smarthome.core.thing.ThingTypeUID in project smarthome by eclipse.
the class InboxConsoleCommandExtension method clearInboxEntries.
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);
}
}
use of org.eclipse.smarthome.core.thing.ThingTypeUID in project smarthome by eclipse.
the class DiscoveryResultDTOMapper method map.
/**
* Maps discovery result data transfer object into discovery result.
*
* @param discoveryResultDTO the discovery result data transfer object
* @return the discovery result
*/
public static DiscoveryResult map(DiscoveryResultDTO discoveryResultDTO) {
final ThingUID thingUID = new ThingUID(discoveryResultDTO.thingUID);
final String dtoThingTypeUID = discoveryResultDTO.thingTypeUID;
final ThingTypeUID thingTypeUID = dtoThingTypeUID != null ? new ThingTypeUID(dtoThingTypeUID) : null;
final String dtoBridgeUID = discoveryResultDTO.bridgeUID;
final ThingUID bridgeUID = dtoBridgeUID != null ? new ThingUID(dtoBridgeUID) : null;
return DiscoveryResultBuilder.create(thingUID).withThingType(thingTypeUID).withBridge(bridgeUID).withLabel(discoveryResultDTO.label).withRepresentationProperty(discoveryResultDTO.representationProperty).withProperties(discoveryResultDTO.properties).build();
}
Aggregations