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;
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);