import org.openhab.core.thing.type.ThingType;
import org.osgi.framework.BundleContext;
import org.osgi.framework.ServiceRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* The {@link DiscoveryServiceManager} manages the different scene and device discovery services and informs them about
public class DiscoveryServiceManager
implements SceneStatusListener, DeviceStatusListener, TemperatureControlStatusListener {
+ private final Logger logger = LoggerFactory.getLogger(DiscoveryServiceManager.class);
+
private final Map<String, AbstractDiscoveryService> discoveryServices;
private final Map<String, ServiceRegistration<?>> discoveryServiceRegs = new HashMap<>();
private final String bridgeUID;
@Override
public void onDeviceAdded(GeneralDeviceInformation device) {
- if (device instanceof Device) {
- String id = ((Device) device).getHWinfo().substring(0, 2);
- if (((Device) device).isSensorDevice()) {
- id = ((Device) device).getHWinfo();
- }
- if (discoveryServices.get(id) != null) {
- ((DeviceDiscoveryService) discoveryServices.get(id)).onDeviceAdded(device);
+ try {
+ if (device instanceof Device) {
+ String id = ((Device) device).getHWinfo().substring(0, 2);
+ if (((Device) device).isSensorDevice()) {
+ id = ((Device) device).getHWinfo();
+ }
+ if (discoveryServices.get(id) != null) {
+ ((DeviceDiscoveryService) discoveryServices.get(id)).onDeviceAdded(device);
+ }
}
- }
- if (device instanceof Circuit) {
- if (discoveryServices.get(DsDeviceThingTypeProvider.SupportedThingTypes.circuit.toString()) != null) {
- ((DeviceDiscoveryService) discoveryServices
- .get(DsDeviceThingTypeProvider.SupportedThingTypes.circuit.toString())).onDeviceAdded(device);
+ if (device instanceof Circuit) {
+ if (discoveryServices.get(DsDeviceThingTypeProvider.SupportedThingTypes.circuit.toString()) != null) {
+ ((DeviceDiscoveryService) discoveryServices
+ .get(DsDeviceThingTypeProvider.SupportedThingTypes.circuit.toString()))
+ .onDeviceAdded(device);
+ }
}
+ } catch (RuntimeException ex) {
+ logger.warn("Unable to add devices {}", device, ex);
}
}