2 * Copyright (c) 2010-2024 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.knx.internal.profiles;
15 import static org.openhab.binding.knx.internal.KNXBindingConstants.*;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
19 import org.openhab.core.thing.Channel;
20 import org.openhab.core.thing.profiles.ProfileAdvisor;
21 import org.openhab.core.thing.profiles.ProfileTypeUID;
22 import org.openhab.core.thing.profiles.SystemProfiles;
23 import org.openhab.core.thing.type.ChannelType;
24 import org.openhab.core.thing.type.ChannelTypeUID;
25 import org.osgi.service.component.annotations.Component;
28 * Advisor, provider and factory for the specialized KNX profiles.
30 * @author Simon Kaufmann - initial contribution and API.
35 public class KNXProfileAdvisor implements ProfileAdvisor {
38 public @Nullable ProfileTypeUID getSuggestedProfileTypeUID(Channel channel, @Nullable String itemType) {
39 ChannelTypeUID channelTypeUID = channel.getChannelTypeUID();
40 if (channelTypeUID == null || !channelTypeUID.getBindingId().equals(BINDING_ID)) {
43 return getSuggestedProfieTypeUID(channelTypeUID);
47 public @Nullable ProfileTypeUID getSuggestedProfileTypeUID(ChannelType channelType, @Nullable String itemType) {
48 return getSuggestedProfieTypeUID(channelType.getUID());
51 private ProfileTypeUID getSuggestedProfieTypeUID(ChannelTypeUID channelTypeUID) {
52 if (isControl(channelTypeUID)) {
53 return SystemProfiles.FOLLOW;
55 return SystemProfiles.DEFAULT;
59 public static boolean isControl(ChannelTypeUID channelTypeUID) {
60 return CONTROL_CHANNEL_TYPES.contains(channelTypeUID.getId());