diff --git a/bundles/org.openhab.binding.boschshc/src/main/java/org/openhab/binding/boschshc/internal/discovery/ThingDiscoveryService.java b/bundles/org.openhab.binding.boschshc/src/main/java/org/openhab/binding/boschshc/internal/discovery/ThingDiscoveryService.java index 411ec2d6a97b9..e912cbd07da18 100644 --- a/bundles/org.openhab.binding.boschshc/src/main/java/org/openhab/binding/boschshc/internal/discovery/ThingDiscoveryService.java +++ b/bundles/org.openhab.binding.boschshc/src/main/java/org/openhab/binding/boschshc/internal/discovery/ThingDiscoveryService.java @@ -56,6 +56,11 @@ public class ThingDiscoveryService extends AbstractThingHandlerDiscoveryService< private final Logger logger = LoggerFactory.getLogger(ThingDiscoveryService.class); + /** + * Device model representing logical child devices of Light Control II + */ + static final String DEVICE_MODEL_LIGHT_CONTROL_CHILD_DEVICE = "MICROMODULE_LIGHT_ATTACHED"; + protected static final Set SUPPORTED_THING_TYPES = Set.of( BoschSHCBindingConstants.THING_TYPE_INWALL_SWITCH, BoschSHCBindingConstants.THING_TYPE_TWINGUARD, BoschSHCBindingConstants.THING_TYPE_WINDOW_CONTACT, BoschSHCBindingConstants.THING_TYPE_WINDOW_CONTACT_2, @@ -285,6 +290,15 @@ private String getNiceName(String name, String roomName) { if (thingTypeId != null) { return new ThingTypeUID(BoschSHCBindingConstants.BINDING_ID, thingTypeId.getId()); } + + if (DEVICE_MODEL_LIGHT_CONTROL_CHILD_DEVICE.equals(device.deviceModel)) { + // Light Control II exposes a parent device and two child devices. + // We only add one thing for the parent device and the child devices are logically included. + // Therefore we do not need to add separate things for the child devices and need to suppress the + // log entry about the unknown device model. + return null; + } + logger.debug("Unknown deviceModel '{}'! Please create a support request issue for this unknown device model.", device.deviceModel); return null; diff --git a/bundles/org.openhab.binding.boschshc/src/test/java/org/openhab/binding/boschshc/internal/discovery/ThingDiscoveryServiceTest.java b/bundles/org.openhab.binding.boschshc/src/test/java/org/openhab/binding/boschshc/internal/discovery/ThingDiscoveryServiceTest.java index 63e3492e0670a..1fb48038fdc02 100644 --- a/bundles/org.openhab.binding.boschshc/src/test/java/org/openhab/binding/boschshc/internal/discovery/ThingDiscoveryServiceTest.java +++ b/bundles/org.openhab.binding.boschshc/src/test/java/org/openhab/binding/boschshc/internal/discovery/ThingDiscoveryServiceTest.java @@ -13,10 +13,16 @@ package org.openhab.binding.boschshc.internal.discovery; import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.CoreMatchers.nullValue; import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.any; -import static org.mockito.Mockito.*; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.when; import java.util.ArrayList; import java.util.UUID; @@ -261,4 +267,12 @@ void testAddUserDefinedStates() { // two calls for the two devices expected verify(discoveryListener, times(2)).thingDiscovered(any(), any()); } + + @Test + void getThingTypeUIDLightControl2ChildDevice() { + Device device = new Device(); + device.deviceModel = ThingDiscoveryService.DEVICE_MODEL_LIGHT_CONTROL_CHILD_DEVICE; + + assertThat(fixture.getThingTypeUID(device), is(nullValue())); + } }