[avmfritz] Do not create a thing type UID using an empty ID (#12617)

Fix #12614

Signed-off-by: Laurent Garnier <lg.hc@free.fr>
pull/12634/head
lolodomo 2022-04-18 19:25:40 +02:00 committed by GitHub
parent c1073cd89f
commit 2d1b337987
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -99,8 +99,9 @@ public class AVMFritzDiscoveryService extends AbstractDiscoveryService
@Override @Override
public void onDeviceAdded(AVMFritzBaseModel device) { public void onDeviceAdded(AVMFritzBaseModel device) {
ThingTypeUID thingTypeUID = new ThingTypeUID(BINDING_ID, bridgeHandler.getThingTypeId(device)); String id = bridgeHandler.getThingTypeId(device);
if (getSupportedThingTypes().contains(thingTypeUID)) { ThingTypeUID thingTypeUID = id.isEmpty() ? null : new ThingTypeUID(BINDING_ID, id);
if (thingTypeUID != null && getSupportedThingTypes().contains(thingTypeUID)) {
ThingUID thingUID = new ThingUID(thingTypeUID, bridgeHandler.getThing().getUID(), ThingUID thingUID = new ThingUID(thingTypeUID, bridgeHandler.getThing().getUID(),
bridgeHandler.getThingName(device)); bridgeHandler.getThingName(device));
onDeviceAddedInternal(thingUID, device); onDeviceAddedInternal(thingUID, device);

View File

@ -297,13 +297,14 @@ public abstract class AVMFritzBaseBridgeHandler extends BaseBridgeHandler {
* @return ThingUID without illegal characters. * @return ThingUID without illegal characters.
*/ */
public @Nullable ThingUID getThingUID(AVMFritzBaseModel device) { 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(); ThingUID bridgeUID = thing.getUID();
String thingName = getThingName(device); 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_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); return new ThingUID(thingTypeUID, bridgeUID, thingName);
} else if (device.isHeatingThermostat()) { } else if (device.isHeatingThermostat()) {
return new ThingUID(GROUP_HEATING_THING_TYPE, bridgeUID, thingName); return new ThingUID(GROUP_HEATING_THING_TYPE, bridgeUID, thingName);