Java Code Examples for org.eclipse.smarthome.config.discovery.DiscoveryService#getSupportedThingTypes()

The following examples show how to use org.eclipse.smarthome.config.discovery.DiscoveryService#getSupportedThingTypes() . 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: DiscoveryServiceRegistryImpl.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
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;
}
 
Example 2
Source File: DiscoveryServiceRegistryImpl.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public List<String> getSupportedBindings() {
    List<String> bindings = new ArrayList<>();
    for (DiscoveryService discoveryService : this.discoveryServices) {
        Collection<ThingTypeUID> supportedThingTypes = discoveryService.getSupportedThingTypes();
        for (ThingTypeUID thingTypeUID : supportedThingTypes) {
            bindings.add(thingTypeUID.getBindingId());
        }
    }
    return bindings;
}
 
Example 3
Source File: DiscoveryServiceRegistryImpl.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
private boolean startScan(DiscoveryService discoveryService, @Nullable ScanListener listener) {
    Collection<ThingTypeUID> supportedThingTypes = discoveryService.getSupportedThingTypes();
    try {
        logger.debug("Triggering scan for thing types '{}' on '{}'...", supportedThingTypes,
                discoveryService.getClass().getSimpleName());

        discoveryService.startScan(listener);
        return true;
    } catch (Exception ex) {
        logger.error("Cannot trigger scan for thing types '{}' on '{}'!", supportedThingTypes,
                discoveryService.getClass().getSimpleName(), ex);
        return false;
    }
}
 
Example 4
Source File: DiscoveryServiceRegistryImpl.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
private synchronized Set<DiscoveryService> getDiscoveryServices(ThingTypeUID thingTypeUID)
        throws IllegalStateException {
    Set<DiscoveryService> discoveryServices = new HashSet<>();

    for (DiscoveryService discoveryService : this.discoveryServices) {
        Collection<ThingTypeUID> discoveryThingTypes = discoveryService.getSupportedThingTypes();
        if (discoveryThingTypes.contains(thingTypeUID)) {
            discoveryServices.add(discoveryService);
        }
    }

    return discoveryServices;
}
 
Example 5
Source File: DiscoveryServiceRegistryImpl.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
private synchronized Set<DiscoveryService> getDiscoveryServices(String bindingId) throws IllegalStateException {
    Set<DiscoveryService> discoveryServices = new HashSet<>();

    for (DiscoveryService discoveryService : this.discoveryServices) {
        Collection<ThingTypeUID> discoveryThingTypes = discoveryService.getSupportedThingTypes();
        for (ThingTypeUID thingTypeUID : discoveryThingTypes) {
            if (thingTypeUID.getBindingId().equals(bindingId)) {
                discoveryServices.add(discoveryService);
            }
        }
    }

    return discoveryServices;
}