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