diff --git a/bundles/org.openhab.binding.smsmodem/src/main/java/org/openhab/binding/smsmodem/internal/SMSConversationDiscoveryService.java b/bundles/org.openhab.binding.smsmodem/src/main/java/org/openhab/binding/smsmodem/internal/SMSConversationDiscoveryService.java index 6b8b9db33e038..c08f2ee3ed040 100644 --- a/bundles/org.openhab.binding.smsmodem/src/main/java/org/openhab/binding/smsmodem/internal/SMSConversationDiscoveryService.java +++ b/bundles/org.openhab.binding.smsmodem/src/main/java/org/openhab/binding/smsmodem/internal/SMSConversationDiscoveryService.java @@ -56,8 +56,10 @@ protected void startScan() { public void buildDiscovery(String sender) { String senderSanitized = sender.replaceAll("[^a-zA-Z0-9+]", "_"); - ThingUID thingUID = SMSModemHandlerFactory - .getSMSConversationUID(SMSModemBindingConstants.SMSCONVERSATION_THING_TYPE, senderSanitized, bridgeUid); + + ThingUID thingUID = new ThingUID(SMSModemBindingConstants.SMSCONVERSATION_THING_TYPE, senderSanitized, + bridgeUid.getId()); + DiscoveryResult result = DiscoveryResultBuilder.create(thingUID) .withProperty(SMSModemBindingConstants.SMSCONVERSATION_PARAMETER_RECIPIENT, senderSanitized) .withLabel("Conversation with " + sender).withBridge(bridgeUid) diff --git a/bundles/org.openhab.binding.smsmodem/src/main/java/org/openhab/binding/smsmodem/internal/SMSModemHandlerFactory.java b/bundles/org.openhab.binding.smsmodem/src/main/java/org/openhab/binding/smsmodem/internal/SMSModemHandlerFactory.java index 30bda0b6fb73d..66d6bd83997f1 100644 --- a/bundles/org.openhab.binding.smsmodem/src/main/java/org/openhab/binding/smsmodem/internal/SMSModemHandlerFactory.java +++ b/bundles/org.openhab.binding.smsmodem/src/main/java/org/openhab/binding/smsmodem/internal/SMSModemHandlerFactory.java @@ -19,12 +19,10 @@ import org.eclipse.jdt.annotation.Nullable; import org.openhab.binding.smsmodem.internal.handler.SMSConversationHandler; import org.openhab.binding.smsmodem.internal.handler.SMSModemBridgeHandler; -import org.openhab.core.config.core.Configuration; import org.openhab.core.io.transport.serial.SerialPortManager; import org.openhab.core.thing.Bridge; import org.openhab.core.thing.Thing; import org.openhab.core.thing.ThingTypeUID; -import org.openhab.core.thing.ThingUID; import org.openhab.core.thing.binding.BaseThingHandlerFactory; import org.openhab.core.thing.binding.ThingHandler; import org.openhab.core.thing.binding.ThingHandlerFactory; @@ -75,31 +73,4 @@ public boolean supportsThingType(ThingTypeUID thingTypeUID) { return null; } - - @Override - public @Nullable Thing createThing(ThingTypeUID thingTypeUID, Configuration configuration, - @Nullable ThingUID thingUID, @Nullable ThingUID bridgeUID) { - if (SMSModemBridgeHandler.SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID)) { - return super.createThing(thingTypeUID, configuration, thingUID, null); - } - if (SMSConversationHandler.SUPPORTED_THING_TYPES_UIDS.equals(thingTypeUID)) { - if (bridgeUID != null) { - ThingUID safethingUID = thingUID == null - ? getSMSConversationUID(thingTypeUID, - (String) configuration - .get(SMSModemBindingConstants.SMSCONVERSATION_PARAMETER_RECIPIENT), - bridgeUID) - : thingUID; - return super.createThing(thingTypeUID, configuration, safethingUID, bridgeUID); - } else { - throw new IllegalArgumentException("Cannot create a SMSConversation without a SMSModem bridge"); - } - - } - throw new IllegalArgumentException("The thing type " + thingTypeUID + " is not supported by the binding."); - } - - public static ThingUID getSMSConversationUID(ThingTypeUID thingTypeUID, String recipient, ThingUID bridgeUID) { - return new ThingUID(thingTypeUID, recipient, bridgeUID.getId()); - } } diff --git a/bundles/org.openhab.binding.smsmodem/src/main/java/org/openhab/binding/smsmodem/internal/handler/SMSModemBridgeHandler.java b/bundles/org.openhab.binding.smsmodem/src/main/java/org/openhab/binding/smsmodem/internal/handler/SMSModemBridgeHandler.java index 54c29f4c9d503..f10eee8118e48 100644 --- a/bundles/org.openhab.binding.smsmodem/src/main/java/org/openhab/binding/smsmodem/internal/handler/SMSModemBridgeHandler.java +++ b/bundles/org.openhab.binding.smsmodem/src/main/java/org/openhab/binding/smsmodem/internal/handler/SMSModemBridgeHandler.java @@ -132,6 +132,7 @@ protected void updateConfiguration(Configuration configuration) { @Override public void initialize() { + updateStatus(ThingStatus.UNKNOWN); shouldRun = true; ScheduledFuture checkScheduledFinal = checkScheduled; if (checkScheduledFinal == null || (checkScheduledFinal.isDone()) && this.shouldRun) {