]> git.basschouten.com Git - openhab-addons.git/blob
50fdfc9b03b0dace97f16a966912d8b942031f45
[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.Objects;
19 import java.util.Set;
20
21 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import org.openhab.core.library.types.PercentType;
23 import org.openhab.core.library.types.StopMoveType;
24 import org.openhab.core.library.types.UpDownType;
25 import org.openhab.core.thing.Channel;
26
27 import tuwien.auto.calimero.dptxlator.DPTXlator8BitUnsigned;
28 import tuwien.auto.calimero.dptxlator.DPTXlatorBoolean;
29
30 /**
31  * rollershutter channel type description
32  *
33  * @author Simon Kaufmann - initial contribution and API.
34  *
35  */
36 @NonNullByDefault
37 class TypeRollershutter extends KNXChannel {
38     public static final Set<String> SUPPORTED_CHANNEL_TYPES = Set.of(CHANNEL_ROLLERSHUTTER,
39             CHANNEL_ROLLERSHUTTER_CONTROL);
40
41     TypeRollershutter(Channel channel) {
42         super(List.of(UP_DOWN_GA, STOP_MOVE_GA, POSITION_GA),
43                 List.of(PercentType.class, UpDownType.class, StopMoveType.class), channel);
44     }
45
46     @Override
47     protected String getDefaultDPT(String gaConfigKey) {
48         if (Objects.equals(gaConfigKey, UP_DOWN_GA)) {
49             return DPTXlatorBoolean.DPT_UPDOWN.getID();
50         }
51         if (Objects.equals(gaConfigKey, STOP_MOVE_GA)) {
52             return DPTXlatorBoolean.DPT_START.getID();
53         }
54         if (Objects.equals(gaConfigKey, POSITION_GA)) {
55             return DPTXlator8BitUnsigned.DPT_SCALING.getID();
56         }
57         throw new IllegalArgumentException("GA configuration '" + gaConfigKey + "' is not supported");
58     }
59 }