]> git.basschouten.com Git - openhab-addons.git/commitdiff
[mycroft] Adjust thread name for web socket client (#14342)
authorlolodomo <lg.hc@free.fr>
Sun, 19 Feb 2023 19:59:18 +0000 (20:59 +0100)
committerGitHub <noreply@github.com>
Sun, 19 Feb 2023 19:59:18 +0000 (20:59 +0100)
Signed-off-by: Laurent Garnier <lg.hc@free.fr>
bundles/org.openhab.binding.mycroft/src/main/java/org/openhab/binding/mycroft/internal/MycroftHandler.java

index bb132c37e823ca8295ee6905642a33e25b3b72f3..7b00fa03186325287dbd2661576da748c459a20a 100644 (file)
@@ -43,6 +43,7 @@ import org.openhab.core.thing.Thing;
 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 class MycroftHandler extends BaseThingHandler implements MycroftConnectio
 
         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);