]> git.basschouten.com Git - openhab-addons.git/commitdiff
[avmfritz] Do not create a thing type UID using an empty ID (#12617)
authorlolodomo <lg.hc@free.fr>
Mon, 18 Apr 2022 17:25:40 +0000 (19:25 +0200)
committerGitHub <noreply@github.com>
Mon, 18 Apr 2022 17:25:40 +0000 (19:25 +0200)
Fix #12614

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/discovery/AVMFritzDiscoveryService.java
bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/AVMFritzBaseBridgeHandler.java

index 946f21a2ef7037b604acdf5967f91e0967d4a6b6..596b73d3c385f532bf8c8530574658d028d7d933 100644 (file)
@@ -99,8 +99,9 @@ public class AVMFritzDiscoveryService extends AbstractDiscoveryService
 
     @Override
     public void onDeviceAdded(AVMFritzBaseModel device) {
-        ThingTypeUID thingTypeUID = new ThingTypeUID(BINDING_ID, bridgeHandler.getThingTypeId(device));
-        if (getSupportedThingTypes().contains(thingTypeUID)) {
+        String id = bridgeHandler.getThingTypeId(device);
+        ThingTypeUID thingTypeUID = id.isEmpty() ? null : new ThingTypeUID(BINDING_ID, id);
+        if (thingTypeUID != null && getSupportedThingTypes().contains(thingTypeUID)) {
             ThingUID thingUID = new ThingUID(thingTypeUID, bridgeHandler.getThing().getUID(),
                     bridgeHandler.getThingName(device));
             onDeviceAddedInternal(thingUID, device);
index fee924a8113ee8e432d49da9c223a2e091a39fac..50d150bea8ac8aaf629e82978ebf66615961d6ad 100644 (file)
@@ -297,13 +297,14 @@ public abstract class AVMFritzBaseBridgeHandler extends BaseBridgeHandler {
      * @return ThingUID without illegal characters.
      */
     public @Nullable ThingUID getThingUID(AVMFritzBaseModel device) {
-        ThingTypeUID thingTypeUID = new ThingTypeUID(BINDING_ID, getThingTypeId(device));
+        String id = getThingTypeId(device);
+        ThingTypeUID thingTypeUID = id.isEmpty() ? null : new ThingTypeUID(BINDING_ID, id);
         ThingUID bridgeUID = thing.getUID();
         String thingName = getThingName(device);
 
-        if (SUPPORTED_BUTTON_THING_TYPES_UIDS.contains(thingTypeUID)
+        if (thingTypeUID != null && (SUPPORTED_BUTTON_THING_TYPES_UIDS.contains(thingTypeUID)
                 || SUPPORTED_HEATING_THING_TYPES.contains(thingTypeUID)
-                || SUPPORTED_DEVICE_THING_TYPES_UIDS.contains(thingTypeUID)) {
+                || SUPPORTED_DEVICE_THING_TYPES_UIDS.contains(thingTypeUID))) {
             return new ThingUID(thingTypeUID, bridgeUID, thingName);
         } else if (device.isHeatingThermostat()) {
             return new ThingUID(GROUP_HEATING_THING_TYPE, bridgeUID, thingName);