diff --git a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/items/ItemUIRegistryImpl.java b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/items/ItemUIRegistryImpl.java index 1862082e2e8..8a96b4b9532 100644 --- a/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/items/ItemUIRegistryImpl.java +++ b/bundles/org.openhab.core.ui/src/main/java/org/openhab/core/ui/internal/items/ItemUIRegistryImpl.java @@ -515,7 +515,8 @@ private QuantityType convertStateToWidgetUnit(QuantityType quantityState, "Item '{}' with unit, nothing allowed after unit in label pattern '{}', dropping postfix", itemName, pattern); } - pattern = pattern.substring(0, matcherEnd) + (!unit.isBlank() ? " " + unit : ""); + pattern = unit.isBlank() ? pattern.substring(0, matcherEnd) + : pattern.substring(0, pattern.indexOf(unit, matcherEnd) + unit.length()); } } catch (ItemNotFoundException e) { logger.warn("Cannot retrieve item '{}' for widget {}", itemName, w.eClass().getInstanceTypeName());