]> git.basschouten.com Git - openhab-addons.git/blob
a7f69cf61e30568314579d9813550b40af6c729a
[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.digitalstrom.internal.lib.structure.devices.deviceparameters.constants;
14
15 import java.util.HashMap;
16 import java.util.Map;
17
18 /**
19  * The {@link OutputChannelEnum} lists all available digitalSTROM-device output
20  * channels:
21  * 
22  * <pre>
23      | ID  | Description                           | Channel Name                                                         | Min | Max   | Unit                 |
24      | --- | ------------------------------------- | -------------------------------------------------------------------- | --- | ----- | -------------------- |
25      | 1   | Light Brightness                      | brightness                                                           | 0   | 100   | percent              |
26      | 2   | Colored Light Hue                     | hue                                                                  | 0   | 360   | degrees              |
27      | 3   | Colored Light Saturation              | saturation                                                           | 0   | 100   | percent              |
28      | 4   | Color Temperature                     | colortemp                                                            | 100 | 1000  | mired                |
29      | 5   | Light CIE Color Model x               | x                                                                    | 0   | 10000 | scaled to 0.0 to 1.0 |
30      | 6   | Light CIE Color Model y               | y                                                                    | 0   | 10000 | scaled to 0.0 to 1.0 |
31      | 7   | Shade Position Outside (blinds)       | shadePositionOutside                                                 | 0   | 100   | percent              |
32      | 8   | Shade Position Outside (curtains)     | shadePositionIndoor                                                  | 0   | 100   | percent              |
33      | 9   | Shade Opening Angle Outside (blinds)  | shadeOpeningAngleOutside                                             | 0   | 100   | percent              |
34      | 10  | Shade Opening Angle Indoor (curtains) | shadeOpeningAngleIndoor                                              | 0   | 100   | percent              |
35      | 11  | Transparency (e.g. smart glass)       | transparency                                                         | 0   | 100   | percent              |
36      | 12  | Air Flow Intensity                    | airFlowIntensity                                                     | 0   | 100   | percent              |
37      | 13  | Air Flow Direction                    | airFlowDirection - 0=both(undefined), 1=supply, (in),2=exhaust (out) | 0   | 2     | specific             |
38      | 14  | Flap Opening Angle                    | airFlapPosition                                                      | 0   | 100   | percent              |
39      | 15  | Ventilation Louver Position           | airLouverPosition                                                    | 0   | 100   | percent              |
40      | 16  | Heating Power                         | heatingPower                                                         | 0   | 100   | percent              |
41      | 17  | Cooling Capacity                      | coolingCapacity                                                      | 0   | 100   | percent              |
42      | 18  | Audio Volume (loudness)               | audioVolume                                                          | 0   | 100   | percent              |
43      | 19  | Power State                           | powerState - 0=powerOff, 1=powerOn, 2=forcedOff, 3=standby           | 0   | 2     | specific             |
44      | 20  | Ventilation swing mode                | airLouverAuto - 0=not active, 1=active                               | 0   | 1     | specific             |
45      | 21  | Ventilation auto intensity            | airFlowAuto - 0=not active, 1=active                                 | 0   | 1     | specific             |
46      | 22  | Water Temperature                     | waterTemperature                                                     | 0   | 150   | celsius              |
47      | 23  | Water Flow Rate                       | waterFlow                                                            | 0   | 100   | percent              |
48      | 24  | Power Level                           | powerLevel                                                           | 0   | 100   | percent              |
49  * </pre>
50  *
51  * @author Rouven Schürch - Initial contribution
52  * @see <a href="http://developer.digitalstrom.org/Architecture/ds-basics.pdf">ds-basics.pdf</a> (Version 1.4/1.6),
53  *      chapter
54  *      9.1 (Output Channel Types), Table 6: Output channel types
55  */
56 public enum OutputChannelEnum {
57
58     BRIGHTNESS(1, "brightness"),
59     HUE(2, "hue"),
60     SATURATION(3, "saturation"),
61     COLORTEMP(4, "colortemp"),
62     X(5, "x"),
63     Y(6, "y"),
64     SHADE_POSITION_OUTSIDE(7, "shadePositionOutside"),
65     SHADE_POSITION_INDOOR(8, "shadePositionIndoor"),
66     SHADE_OPENING_ANGLE_OUTSIDE(9, "shadeOpeningAngleOutside"),
67     SHADE_OPENING_ANGLE_INDOOR(10, "shadeOpeningAngleIndoor"),
68     TRANSPARENCY(11, "transparency"),
69     AIR_FLOW_INTENSITY(12, "airFlowIntensity"),
70     AIR_FLOW_DIRECTION(13, "airFlowDirection"),
71     AIR_FLAP_POSITION(14, "airFlapPosition"),
72     AIR_LOUVER_POSITION(15, "airLouverPosition"),
73     HEATING_POWER(16, "heatingPower"),
74     COOLING_CAPACITY(17, "coolingCapacity"),
75     AUDIO_VOLUME(18, "audioVolume"),
76     POWER_STATE(19, "powerState"),
77     AIR_LOUVER_AUTO(20, "airLouverAuto"),
78     AIR_FLOW_AUTO(21, "airFlowAuto"),
79     WATER_TEMPERATURE(22, "waterTemperature"),
80     WATER_FLOW(23, "waterFlow"),
81     POWER_LEVEL(24, "powerLevel");
82
83     private final int channelId;
84
85     private final String name;
86
87     static final Map<Integer, OutputChannelEnum> OUTPUT_CHANNELS = new HashMap<>();
88
89     static {
90         for (OutputChannelEnum channels : OutputChannelEnum.values()) {
91             OUTPUT_CHANNELS.put(channels.getChannelId(), channels);
92         }
93     }
94
95     /**
96      * Returns true, if the output channel id is contained in digitalSTROM,
97      * otherwise false.
98      *
99      * @param channelID to be checked
100      * @return true, if contains, otherwise false
101      */
102     public static boolean containsChannel(Integer channelID) {
103         return OUTPUT_CHANNELS.keySet().contains(channelID);
104     }
105
106     /**
107      * Returns the {@link OutputChannelEnum} for the given channelID, otherwise
108      * null.
109      *
110      * @param channelID of the {@link OutputChannelEnum}
111      * @return OutputChannelEnum or null
112      */
113     public static OutputChannelEnum getChannel(Integer channelID) {
114         return OUTPUT_CHANNELS.get(channelID);
115     }
116
117     private OutputChannelEnum(int channelId, String name) {
118         this.channelId = channelId;
119         this.name = name;
120     }
121
122     /**
123      * Returns the id of this {@link OutputChannelEnum} object.
124      *
125      * @return mode id
126      */
127     public int getChannelId() {
128         return channelId;
129     }
130
131     /**
132      * 
133      * @return the name of this {@link OutputChannelEnum} object.
134      */
135     public String getName() {
136         return name;
137     }
138
139     public static boolean isShadeChannel(OutputChannelEnum outputChannelEnum) {
140         return outputChannelEnum == OutputChannelEnum.SHADE_OPENING_ANGLE_INDOOR
141                 || outputChannelEnum == OutputChannelEnum.SHADE_OPENING_ANGLE_OUTSIDE
142                 || outputChannelEnum == OutputChannelEnum.SHADE_POSITION_INDOOR
143                 || outputChannelEnum == OutputChannelEnum.SHADE_POSITION_OUTSIDE;
144     }
145 }