diff --git a/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/handler/AbstractBrokerHandler.java b/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/handler/AbstractBrokerHandler.java index 6eb28d78233..f68f65f69e9 100644 --- a/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/handler/AbstractBrokerHandler.java +++ b/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/handler/AbstractBrokerHandler.java @@ -114,8 +114,6 @@ public abstract class AbstractBrokerHandler extends BaseBridgeHandler implements }).thenAccept(v -> { if (!v) { connectionStateChanged(MqttConnectionState.DISCONNECTED, new TimeoutException("Timeout")); - } else { - connectionStateChanged(MqttConnectionState.CONNECTED, null); } }); connectionFuture.complete(connection); diff --git a/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/handler/BrokerHandler.java b/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/handler/BrokerHandler.java index d7cf35686a6..c48da5ccd09 100644 --- a/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/handler/BrokerHandler.java +++ b/bundles/org.openhab.binding.mqtt/src/main/java/org/openhab/binding/mqtt/handler/BrokerHandler.java @@ -59,19 +59,18 @@ public class BrokerHandler extends AbstractBrokerHandler implements PinnedCallba @Override public void connectionStateChanged(MqttConnectionState state, @Nullable Throwable error) { super.connectionStateChanged(state, error); - // Store generated client ID if none was set by the user final MqttBrokerConnection connection = this.connection; - String clientID = config.clientID; if (connection != null && state == MqttConnectionState.CONNECTED) { + String clientID = config.clientID; if (clientID == null || clientID.isBlank()) { + // Store generated client ID if none was set by the user clientID = connection.getClientId(); config.clientID = clientID; Configuration editConfig = editConfiguration(); editConfig.put("clientid", clientID); updateConfiguration(editConfig); - } else { - publish(config.birthTopic, config.birthMessage, config.birthRetain); } + publish(config.birthTopic, config.birthMessage, config.birthRetain); } }