]> git.basschouten.com Git - openhab-addons.git/blob
5e01f0386ba8d528e967673f79bb73f1fbc6f36d
[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 org.openhab.binding.knx.internal.KNXBindingConstants.*;
16
17 import java.util.Objects;
18 import java.util.Set;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21
22 import tuwien.auto.calimero.dptxlator.DPTXlator3BitControlled;
23 import tuwien.auto.calimero.dptxlator.DPTXlator8BitUnsigned;
24 import tuwien.auto.calimero.dptxlator.DPTXlatorBoolean;
25
26 /**
27  * dimmer channel type description
28  *
29  * @author Simon Kaufmann - initial contribution and API.
30  *
31  */
32 @NonNullByDefault
33 class TypeDimmer extends KNXChannelType {
34
35     TypeDimmer() {
36         super(CHANNEL_DIMMER, CHANNEL_DIMMER_CONTROL);
37     }
38
39     @Override
40     protected Set<String> getAllGAKeys() {
41         return Set.of(SWITCH_GA, POSITION_GA, INCREASE_DECREASE_GA);
42     }
43
44     @Override
45     protected String getDefaultDPT(String gaConfigKey) {
46         if (Objects.equals(gaConfigKey, INCREASE_DECREASE_GA)) {
47             return DPTXlator3BitControlled.DPT_CONTROL_DIMMING.getID();
48         }
49         if (Objects.equals(gaConfigKey, SWITCH_GA)) {
50             return DPTXlatorBoolean.DPT_SWITCH.getID();
51         }
52         if (Objects.equals(gaConfigKey, POSITION_GA)) {
53             return DPTXlator8BitUnsigned.DPT_SCALING.getID();
54         }
55         throw new IllegalArgumentException("GA configuration '" + gaConfigKey + "' is not supported");
56     }
57 }