diff --git a/bundles/org.openhab.binding.mycroft/src/main/java/org/openhab/binding/mycroft/internal/MycroftHandler.java b/bundles/org.openhab.binding.mycroft/src/main/java/org/openhab/binding/mycroft/internal/MycroftHandler.java index bb132c37e823c..7b00fa0318632 100644 --- a/bundles/org.openhab.binding.mycroft/src/main/java/org/openhab/binding/mycroft/internal/MycroftHandler.java +++ b/bundles/org.openhab.binding.mycroft/src/main/java/org/openhab/binding/mycroft/internal/MycroftHandler.java @@ -43,6 +43,7 @@ import org.openhab.core.thing.ThingStatus; import org.openhab.core.thing.ThingStatusDetail; import org.openhab.core.thing.binding.BaseThingHandler; +import org.openhab.core.thing.util.ThingWebClientUtil; import org.openhab.core.types.Command; import org.openhab.core.types.State; import org.slf4j.Logger; @@ -126,13 +127,7 @@ public void initialize() { logger.debug("Start initializing Mycroft {}", thing.getUID()); - String websocketID = thing.getUID().getAsString().replace(':', '-'); - if (websocketID.length() < 4) { - websocketID = "mycroft-" + websocketID; - } - if (websocketID.length() > 20) { - websocketID = websocketID.substring(websocketID.length() - 20); - } + String websocketID = ThingWebClientUtil.buildWebClientConsumerName(thing.getUID(), null); this.connection = new MycroftConnection(this, webSocketFactory.createWebSocketClient(websocketID)); config = getConfigAs(MycroftConfiguration.class);