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.channel;
15 import static org.openhab.binding.knx.internal.KNXBindingConstants.*;
17 import java.util.List;
18 import java.util.Objects;
21 import org.eclipse.jdt.annotation.NonNullByDefault;
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;
27 import tuwien.auto.calimero.dptxlator.DPTXlator3BitControlled;
28 import tuwien.auto.calimero.dptxlator.DPTXlator8BitUnsigned;
29 import tuwien.auto.calimero.dptxlator.DPTXlatorBoolean;
32 * dimmer channel type description
34 * @author Simon Kaufmann - initial contribution and API.
38 class TypeDimmer extends KNXChannel {
39 public static final Set<String> SUPPORTED_CHANNEL_TYPES = Set.of(CHANNEL_DIMMER, CHANNEL_DIMMER_CONTROL);
41 TypeDimmer(Channel channel) {
42 super(List.of(SWITCH_GA, POSITION_GA, INCREASE_DECREASE_GA),
43 List.of(PercentType.class, OnOffType.class, IncreaseDecreaseType.class), channel);
47 protected String getDefaultDPT(String gaConfigKey) {
48 if (Objects.equals(gaConfigKey, INCREASE_DECREASE_GA)) {
49 return DPTXlator3BitControlled.DPT_CONTROL_DIMMING.getID();
51 if (Objects.equals(gaConfigKey, SWITCH_GA)) {
52 return DPTXlatorBoolean.DPT_SWITCH.getID();
54 if (Objects.equals(gaConfigKey, POSITION_GA)) {
55 return DPTXlator8BitUnsigned.DPT_SCALING.getID();
57 throw new IllegalArgumentException("GA configuration '" + gaConfigKey + "' is not supported");