From 1a19f695c370a29ca6b12a227e74eca970f6ab7e Mon Sep 17 00:00:00 2001 From: Christoph Weitkamp Date: Thu, 2 Dec 2021 09:07:17 +0100 Subject: [PATCH] [avmfritz] Exclude other Powerline products from discovery (#11682) Signed-off-by: Christoph Weitkamp Signed-off-by: Michael Schmidt --- .../internal/AVMFritzBindingConstants.java | 16 ++++++++-------- .../internal/AVMFritzHandlerFactory.java | 2 +- .../AVMFritzUpnpDiscoveryParticipant.java | 4 ++-- .../internal/handler/Powerline546EHandler.java | 2 +- .../AVMFritzDiscoveryServiceOSGiTest.java | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/AVMFritzBindingConstants.java b/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/AVMFritzBindingConstants.java index 7abd3d26a9648..c9c7354e65230 100644 --- a/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/AVMFritzBindingConstants.java +++ b/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/AVMFritzBindingConstants.java @@ -37,7 +37,7 @@ public class AVMFritzBindingConstants { public static final String BINDING_ID = "avmfritz"; public static final String BRIDGE_FRITZBOX = "fritzbox"; public static final String BOX_MODEL_NAME = "FRITZ!Box"; - public static final String POWERLINE_MODEL_NAME = "FRITZ!Powerline"; + public static final String POWERLINE546E_MODEL_NAME = "FRITZ!Powerline 546E"; // List of main device types public static final String DEVICE_DECT500 = "FRITZ_DECT_500"; @@ -48,8 +48,8 @@ public class AVMFritzBindingConstants { public static final String DEVICE_DECT210 = "FRITZ_DECT_210"; public static final String DEVICE_DECT200 = "FRITZ_DECT_200"; public static final String DEVICE_DECT100 = "FRITZ_DECT_Repeater_100"; - public static final String DEVICE_PL546E = "FRITZ_Powerline_546E"; - public static final String DEVICE_PL546E_STANDALONE = "FRITZ_Powerline_546E_Solo"; + public static final String DEVICE_POWERLINE546E = "FRITZ_Powerline_546E"; + public static final String DEVICE_POWERLINE546E_STANDALONE = "FRITZ_Powerline_546E_Solo"; public static final String DEVICE_COMETDECT = "Comet_DECT"; public static final String DEVICE_HAN_FUN_CONTACT = "HAN_FUN_CONTACT"; public static final String DEVICE_HAN_FUN_SWITCH = "HAN_FUN_SWITCH"; @@ -70,9 +70,9 @@ public class AVMFritzBindingConstants { public static final ThingTypeUID DECT210_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_DECT210); public static final ThingTypeUID DECT200_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_DECT200); public static final ThingTypeUID DECT100_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_DECT100); - public static final ThingTypeUID PL546E_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_PL546E); - public static final ThingTypeUID PL546E_STANDALONE_THING_TYPE = new ThingTypeUID(BINDING_ID, - DEVICE_PL546E_STANDALONE); + public static final ThingTypeUID POWERLINE546E_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_POWERLINE546E); + public static final ThingTypeUID POWERLINE546E_STANDALONE_THING_TYPE = new ThingTypeUID(BINDING_ID, + DEVICE_POWERLINE546E_STANDALONE); public static final ThingTypeUID COMETDECT_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_COMETDECT); public static final ThingTypeUID HAN_FUN_CONTACT_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_HAN_FUN_CONTACT); public static final ThingTypeUID HAN_FUN_SWITCH_THING_TYPE = new ThingTypeUID(BINDING_ID, DEVICE_HAN_FUN_SWITCH); @@ -176,14 +176,14 @@ public class AVMFritzBindingConstants { COMETDECT_THING_TYPE); public static final Set SUPPORTED_DEVICE_THING_TYPES_UIDS = Set.of(DECT100_THING_TYPE, - DECT200_THING_TYPE, DECT210_THING_TYPE, PL546E_THING_TYPE, HAN_FUN_CONTACT_THING_TYPE, + DECT200_THING_TYPE, DECT210_THING_TYPE, POWERLINE546E_THING_TYPE, HAN_FUN_CONTACT_THING_TYPE, HAN_FUN_ON_OFF_THING_TYPE, HAN_FUN_BLINDS_THING_TYPE); public static final Set SUPPORTED_GROUP_THING_TYPES_UIDS = Set.of(GROUP_HEATING_THING_TYPE, GROUP_SWITCH_THING_TYPE); public static final Set SUPPORTED_BRIDGE_THING_TYPES_UIDS = Set.of(BRIDGE_THING_TYPE, - PL546E_STANDALONE_THING_TYPE); + POWERLINE546E_STANDALONE_THING_TYPE); public static final Set SUPPORTED_THING_TYPES_UIDS = Stream.of(SUPPORTED_LIGHTING_THING_TYPES, SUPPORTED_BUTTON_THING_TYPES_UIDS, SUPPORTED_HEATING_THING_TYPES, SUPPORTED_DEVICE_THING_TYPES_UIDS, diff --git a/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/AVMFritzHandlerFactory.java b/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/AVMFritzHandlerFactory.java index 5d396a2c66aa7..386c33b530b86 100644 --- a/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/AVMFritzHandlerFactory.java +++ b/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/AVMFritzHandlerFactory.java @@ -75,7 +75,7 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) { ThingTypeUID thingTypeUID = thing.getThingTypeUID(); if (BRIDGE_THING_TYPE.equals(thingTypeUID)) { return new BoxHandler((Bridge) thing, httpClient, commandDescriptionProvider); - } else if (PL546E_STANDALONE_THING_TYPE.equals(thingTypeUID)) { + } else if (POWERLINE546E_STANDALONE_THING_TYPE.equals(thingTypeUID)) { return new Powerline546EHandler((Bridge) thing, httpClient, commandDescriptionProvider); } else if (SUPPORTED_LIGHTING_THING_TYPES.contains(thingTypeUID)) { return new AVMFritzColorLightDeviceHandler(thing); diff --git a/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/discovery/AVMFritzUpnpDiscoveryParticipant.java b/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/discovery/AVMFritzUpnpDiscoveryParticipant.java index fa42200ce5a0a..d5c160b89a7d8 100644 --- a/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/discovery/AVMFritzUpnpDiscoveryParticipant.java +++ b/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/discovery/AVMFritzUpnpDiscoveryParticipant.java @@ -109,9 +109,9 @@ public Set getSupportedThingTypeUIDs() { if (modelName.startsWith(BOX_MODEL_NAME)) { logger.debug("discovered on {}", device.getIdentity().getDiscoveredOnLocalAddress()); return new ThingUID(BRIDGE_THING_TYPE, id); - } else if (modelName.startsWith(POWERLINE_MODEL_NAME)) { + } else if (POWERLINE546E_MODEL_NAME.equals(modelName)) { logger.debug("discovered on {}", device.getIdentity().getDiscoveredOnLocalAddress()); - return new ThingUID(PL546E_STANDALONE_THING_TYPE, id); + return new ThingUID(POWERLINE546E_STANDALONE_THING_TYPE, id); } } } diff --git a/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/Powerline546EHandler.java b/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/Powerline546EHandler.java index dc5176a0c4788..f84c2b75e8948 100644 --- a/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/Powerline546EHandler.java +++ b/bundles/org.openhab.binding.avmfritz/src/main/java/org/openhab/binding/avmfritz/internal/handler/Powerline546EHandler.java @@ -225,7 +225,7 @@ public void onDeviceGone(ThingUID thingUID) { ThingTypeUID thingTypeUID = new ThingTypeUID(BINDING_ID, getThingTypeId(device).concat("_Solo")); String ipAddress = getConfigAs(AVMFritzBoxConfiguration.class).ipAddress; - if (PL546E_STANDALONE_THING_TYPE.equals(thingTypeUID)) { + if (POWERLINE546E_STANDALONE_THING_TYPE.equals(thingTypeUID)) { String thingName = "fritz.powerline".equals(ipAddress) ? ipAddress : ipAddress.replaceAll(INVALID_PATTERN, "_"); return new ThingUID(thingTypeUID, thingName); diff --git a/itests/org.openhab.binding.avmfritz.tests/src/main/java/org/openhab/binding/avmfritz/internal/discovery/AVMFritzDiscoveryServiceOSGiTest.java b/itests/org.openhab.binding.avmfritz.tests/src/main/java/org/openhab/binding/avmfritz/internal/discovery/AVMFritzDiscoveryServiceOSGiTest.java index 26d7dd3eb6c35..ce927e9a6f5db 100644 --- a/itests/org.openhab.binding.avmfritz.tests/src/main/java/org/openhab/binding/avmfritz/internal/discovery/AVMFritzDiscoveryServiceOSGiTest.java +++ b/itests/org.openhab.binding.avmfritz.tests/src/main/java/org/openhab/binding/avmfritz/internal/discovery/AVMFritzDiscoveryServiceOSGiTest.java @@ -98,7 +98,7 @@ public void correctSupportedTypes() { assertTrue(discovery.getSupportedThingTypes().contains(DECT400_THING_TYPE)); assertTrue(discovery.getSupportedThingTypes().contains(DECT440_THING_TYPE)); assertTrue(discovery.getSupportedThingTypes().contains(DECT500_THING_TYPE)); - assertTrue(discovery.getSupportedThingTypes().contains(PL546E_THING_TYPE)); + assertTrue(discovery.getSupportedThingTypes().contains(POWERLINE546E_THING_TYPE)); assertTrue(discovery.getSupportedThingTypes().contains(COMETDECT_THING_TYPE)); assertTrue(discovery.getSupportedThingTypes().contains(HAN_FUN_CONTACT_THING_TYPE)); assertTrue(discovery.getSupportedThingTypes().contains(HAN_FUN_SWITCH_THING_TYPE)); @@ -508,7 +508,7 @@ public void validPowerline546EDiscoveryResult() throws JAXBException, XMLStreamE assertEquals(DiscoveryResultFlag.NEW, discoveryResult.getFlag()); assertEquals(new ThingUID("avmfritz:FRITZ_Powerline_546E:1:5C_49_79_F0_A3_84"), discoveryResult.getThingUID()); - assertEquals(PL546E_THING_TYPE, discoveryResult.getThingTypeUID()); + assertEquals(POWERLINE546E_THING_TYPE, discoveryResult.getThingTypeUID()); assertEquals(BRIGE_THING_ID, discoveryResult.getBridgeUID()); assertEquals("5C:49:79:F0:A3:84", discoveryResult.getProperties().get(CONFIG_AIN)); assertEquals("AVM", discoveryResult.getProperties().get(PROPERTY_VENDOR));