]> git.basschouten.com Git - openhab-addons.git/blob
07f2599f6af13d50611683d7d04cc69f16f25f66
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2024 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.knx.internal.channel;
14
15 import static org.openhab.binding.knx.internal.KNXBindingConstants.*;
16
17 import java.util.List;
18 import java.util.Set;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.openhab.core.library.types.HSBType;
22 import org.openhab.core.library.types.IncreaseDecreaseType;
23 import org.openhab.core.library.types.OnOffType;
24 import org.openhab.core.library.types.PercentType;
25 import org.openhab.core.thing.Channel;
26
27 import tuwien.auto.calimero.dptxlator.DPTXlator3BitControlled;
28 import tuwien.auto.calimero.dptxlator.DPTXlator8BitUnsigned;
29 import tuwien.auto.calimero.dptxlator.DPTXlatorBoolean;
30 import tuwien.auto.calimero.dptxlator.DPTXlatorRGB;
31
32 /**
33  * color channel type description
34  *
35  * @author Helmut Lehmeyer - initial contribution
36  *
37  */
38 @NonNullByDefault
39 class TypeColor extends KNXChannel {
40     public static final Set<String> SUPPORTED_CHANNEL_TYPES = Set.of(CHANNEL_COLOR, CHANNEL_COLOR_CONTROL);
41
42     TypeColor(Channel channel) {
43         super(List.of(SWITCH_GA, POSITION_GA, INCREASE_DECREASE_GA, HSB_GA),
44                 List.of(HSBType.class, PercentType.class, OnOffType.class, IncreaseDecreaseType.class), channel);
45     }
46
47     @Override
48     protected String getDefaultDPT(String gaConfigKey) {
49         if (gaConfigKey.equals(HSB_GA)) {
50             return DPTXlatorRGB.DPT_RGB.getID();
51         }
52         if (gaConfigKey.equals(INCREASE_DECREASE_GA)) {
53             return DPTXlator3BitControlled.DPT_CONTROL_DIMMING.getID();
54         }
55         if (gaConfigKey.equals(SWITCH_GA)) {
56             return DPTXlatorBoolean.DPT_SWITCH.getID();
57         }
58         if (gaConfigKey.equals(POSITION_GA)) {
59             return DPTXlator8BitUnsigned.DPT_SCALING.getID();
60         }
61         throw new IllegalArgumentException("GA configuration '" + gaConfigKey + "' is not supported");
62     }
63 }