Skip to content

Commit 9f80bbf

Browse files
authoredJul 14, 2024
Add default scope to profile when loading items file (#4314)
* Add default scope to profile when loading items file Fix #4277 Signed-off-by: Laurent Garnier <lg.hc@free.fr>
1 parent 98554af commit 9f80bbf

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
 

‎bundles/org.openhab.core.model.thing/src/org/openhab/core/model/thing/internal/GenericItemChannelLinkProvider.java

+12
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import org.openhab.core.thing.ChannelUID;
3131
import org.openhab.core.thing.link.ItemChannelLink;
3232
import org.openhab.core.thing.link.ItemChannelLinkProvider;
33+
import org.openhab.core.thing.profiles.ProfileTypeUID;
3334
import org.osgi.service.component.annotations.Component;
3435
import org.slf4j.Logger;
3536
import org.slf4j.LoggerFactory;
@@ -88,6 +89,17 @@ private void createItemChannelLink(String context, String itemName, String chann
8889
} catch (IllegalArgumentException e) {
8990
throw new BindingConfigParseException(e.getMessage());
9091
}
92+
93+
// Fix the configuration in case a profile is defined without any scope
94+
if (configuration.containsKey("profile") && configuration.get("profile") instanceof String profile
95+
&& profile.indexOf(":") == -1) {
96+
String fullProfile = ProfileTypeUID.SYSTEM_SCOPE + ":" + profile;
97+
configuration.put("profile", fullProfile);
98+
logger.info(
99+
"Profile '{}' for channel '{}' is missing the scope prefix, assuming the correct UID is '{}'. Check your configuration.",
100+
profile, channelUID, fullProfile);
101+
}
102+
91103
ItemChannelLink itemChannelLink = new ItemChannelLink(itemName, channelUIDObject, configuration);
92104

93105
Set<String> itemNames = Objects.requireNonNull(contextMap.computeIfAbsent(context, k -> new HashSet<>()));

0 commit comments

Comments
 (0)