[digitalstrom] fixes StringIndexOutOfBoundsException (#9194)
* [digitalstrom] catch issues when adding devices Signed-off-by: Gaétan Collaud <gaetancollaud@gmail.com> * Update bundles/org.openhab.binding.digitalstrom/src/main/java/org/openhab/binding/digitalstrom/internal/discovery/DiscoveryServiceManager.java Signed-off-by: Gaétan Collaud <gaetancollaud@gmail.com>
This commit is contained in:
parent
7582117759
commit
f9866b2c77
@ -40,6 +40,8 @@ import org.openhab.core.thing.ThingTypeUID;
|
||||
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
|
||||
@ -51,6 +53,8 @@ import org.osgi.framework.ServiceRegistration;
|
||||
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;
|
||||
@ -194,20 +198,25 @@ public class DiscoveryServiceManager
|
||||
|
||||
@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();
|
||||
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 (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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user