Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[avmfritz] Exclude other Powerline products from discovery #11682

Merged
merged 2 commits into from
Dec 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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";
Expand All @@ -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);
Expand Down Expand Up @@ -176,14 +176,14 @@ public class AVMFritzBindingConstants {
COMETDECT_THING_TYPE);

public static final Set<ThingTypeUID> 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<ThingTypeUID> SUPPORTED_GROUP_THING_TYPES_UIDS = Set.of(GROUP_HEATING_THING_TYPE,
GROUP_SWITCH_THING_TYPE);

public static final Set<ThingTypeUID> SUPPORTED_BRIDGE_THING_TYPES_UIDS = Set.of(BRIDGE_THING_TYPE,
PL546E_STANDALONE_THING_TYPE);
POWERLINE546E_STANDALONE_THING_TYPE);

public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Stream.of(SUPPORTED_LIGHTING_THING_TYPES,
SUPPORTED_BUTTON_THING_TYPES_UIDS, SUPPORTED_HEATING_THING_TYPES, SUPPORTED_DEVICE_THING_TYPES_UIDS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ public Set<ThingTypeUID> 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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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));
Expand Down