2 * Copyright (c) 2010-2023 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.lcn.internal;
15 import java.util.Collection;
16 import java.util.Locale;
19 import org.eclipse.jdt.annotation.NonNullByDefault;
20 import org.eclipse.jdt.annotation.Nullable;
21 import org.openhab.binding.lcn.internal.common.LcnChannelGroup;
22 import org.openhab.core.library.CoreItemFactory;
23 import org.openhab.core.thing.profiles.Profile;
24 import org.openhab.core.thing.profiles.ProfileCallback;
25 import org.openhab.core.thing.profiles.ProfileContext;
26 import org.openhab.core.thing.profiles.ProfileFactory;
27 import org.openhab.core.thing.profiles.ProfileType;
28 import org.openhab.core.thing.profiles.ProfileTypeBuilder;
29 import org.openhab.core.thing.profiles.ProfileTypeProvider;
30 import org.openhab.core.thing.profiles.ProfileTypeUID;
31 import org.openhab.core.thing.type.ChannelTypeUID;
32 import org.osgi.service.component.annotations.Component;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
37 * Factory to create Profile instances. Also provides the available ProfileTypes and gives advise which profile to use
40 * @author Fabian Wolter - Initial Contribution
43 @Component(service = { ProfileFactory.class, ProfileTypeProvider.class })
44 public class LcnProfileFactory implements ProfileFactory, ProfileTypeProvider {
45 private final Logger logger = LoggerFactory.getLogger(LcnProfileFactory.class);
48 public Collection<ProfileTypeUID> getSupportedProfileTypeUIDs() {
49 return Set.of(DimmerOutputProfile.UID);
53 public Collection<ProfileType> getProfileTypes(@Nullable Locale locale) {
54 return Set.of(ProfileTypeBuilder.newState(DimmerOutputProfile.UID, "Dimmer Output (%)")
55 .withSupportedItemTypes(CoreItemFactory.DIMMER, CoreItemFactory.COLOR)
56 .withSupportedChannelTypeUIDs(
57 new ChannelTypeUID(LcnBindingConstants.BINDING_ID, LcnChannelGroup.OUTPUT.name().toLowerCase()))
62 public @Nullable Profile createProfile(ProfileTypeUID profileTypeUID, ProfileCallback callback,
63 ProfileContext profileContext) {
64 if (profileTypeUID.equals(DimmerOutputProfile.UID)) {
65 return new DimmerOutputProfile(callback, profileContext);
67 logger.warn("Could not create {}", profileTypeUID);