]> git.basschouten.com Git - openhab-addons.git/blob
e79fb4e36fd779702f08e78b7e2303ebea351c10
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 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 java.util.stream.Collectors.toSet;
16 import static org.openhab.binding.knx.internal.KNXBindingConstants.*;
17
18 import java.util.Set;
19 import java.util.stream.Stream;
20
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22
23 import tuwien.auto.calimero.dptxlator.DPTXlator3BitControlled;
24 import tuwien.auto.calimero.dptxlator.DPTXlator8BitUnsigned;
25 import tuwien.auto.calimero.dptxlator.DPTXlatorBoolean;
26 import tuwien.auto.calimero.dptxlator.DPTXlatorRGB;
27
28 /**
29  * color channel type description
30  *
31  * @author Helmut Lehmeyer - initial contribution
32  *
33  */
34 @NonNullByDefault
35 class TypeColor extends KNXChannelType {
36
37     TypeColor() {
38         super(CHANNEL_COLOR, CHANNEL_COLOR_CONTROL);
39     }
40
41     @Override
42     protected Set<String> getAllGAKeys() {
43         return Stream.of(SWITCH_GA, POSITION_GA, INCREASE_DECREASE_GA, HSB_GA).collect(toSet());
44     }
45
46     @Override
47     protected String getDefaultDPT(String gaConfigKey) {
48         if (gaConfigKey.equals(HSB_GA)) {
49             return DPTXlatorRGB.DPT_RGB.getID();
50         }
51         if (gaConfigKey.equals(INCREASE_DECREASE_GA)) {
52             return DPTXlator3BitControlled.DPT_CONTROL_DIMMING.getID();
53         }
54         if (gaConfigKey.equals(SWITCH_GA)) {
55             return DPTXlatorBoolean.DPT_SWITCH.getID();
56         }
57         if (gaConfigKey.equals(POSITION_GA)) {
58             return DPTXlator8BitUnsigned.DPT_SCALING.getID();
59         }
60         throw new IllegalArgumentException("GA configuration '" + gaConfigKey + "' is not supported");
61     }
62 }