]> git.basschouten.com Git - openhab-addons.git/blob
e8fb506eace590afd5e36c9d3a31f777a258ec28
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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 FuncNameAndColorGroupEnum} contains all digitalSTROM functional group names and links to their
20  * {@link FunctionalColorGroupEnum}.
21  *
22  * @author Michael Ochel - Initial contribution
23  * @author Matthias Siegele - Initial contribution
24  * @see <a href="http://developer.digitalstrom.org/Architecture/ds-basics.pdf">ds-basics.pdf
25  *      "Table 1: digitalSTROM functional groups and their colors", page 9</a>
26  */
27 public enum FuncNameAndColorGroupEnum {
28     /*
29      * | Number | Name | Color | Function |
30      * --------------------------------------------------------------------------------------
31      * | 1 | Lights | Yellow | Room lights |
32      * | 2 | Blinds | Gray | Blinds or shades outside |
33      * | 12 | Curtains | Gray | Curtains and blinds inside |
34      * | 3 | Heating | Blue | Heating |
35      * | 9 | Cooling | Blue | Cooling |
36      * | 10 | Ventilation | Blue | Ventilation |
37      * | 11 | Window | Blue | Window |
38      * | 48 | Temperature Control | Blue | Single room temperature control |
39      * | 4 | Audio | Cyan | Playing music or radio |
40      * | 5 | Video | Magenta | TV, Video |
41      * | 8 | Joker | Black | Configurable behaviour |
42      * | n/a | Single Device | White | Various, individual per device |
43      * | n/a | Security | Red | Security related functions, Alarms |
44      * | n/a | Access | Green | Access related functions, door bell |
45      *
46      */
47     LIGHTS((short) 1, FunctionalColorGroupEnum.getColorGroup((short) 1)),
48     BLINDS((short) 2, FunctionalColorGroupEnum.getColorGroup((short) 2)),
49     CURTAINS((short) 12, FunctionalColorGroupEnum.getColorGroup((short) 12)),
50     HEATING((short) 3, FunctionalColorGroupEnum.getColorGroup((short) 3)),
51     COOLING((short) 9, FunctionalColorGroupEnum.getColorGroup((short) 9)),
52     VENTILATION((short) 10, FunctionalColorGroupEnum.getColorGroup((short) 10)),
53     WINDOW((short) 11, FunctionalColorGroupEnum.getColorGroup((short) 11)),
54     TEMPERATION_CONTROL((short) 48, FunctionalColorGroupEnum.getColorGroup((short) 48)),
55     AUDIO((short) 4, FunctionalColorGroupEnum.getColorGroup((short) 4)),
56     VIDEO((short) 5, FunctionalColorGroupEnum.getColorGroup((short) 5)),
57     JOKER((short) 8, FunctionalColorGroupEnum.getColorGroup((short) 8)),
58     SINGLE_DEVICE((short) -1, FunctionalColorGroupEnum.getColorGroup((short) -1)),
59     SECURITY((short) -2, FunctionalColorGroupEnum.getColorGroup((short) -2)),
60     ACCESS((short) -3, FunctionalColorGroupEnum.getColorGroup((short) -3));
61
62     private final short colorGroup;
63     private final FunctionalColorGroupEnum color;
64
65     static final Map<Short, FuncNameAndColorGroupEnum> COLOR_GROUPS = new HashMap<>();
66
67     static {
68         for (FuncNameAndColorGroupEnum colorGroup : FuncNameAndColorGroupEnum.values()) {
69             COLOR_GROUPS.put(colorGroup.getFunctionalColorGroup(), colorGroup);
70         }
71     }
72
73     /**
74      * Returns true, if contains the given output mode id in DigitalSTROM, otherwise false.
75      *
76      * @param functionalNameGroupID to be checked
77      * @return true, if contains
78      */
79     public static boolean containsColorGroup(Short functionalNameGroupID) {
80         return COLOR_GROUPS.keySet().contains(functionalNameGroupID);
81     }
82
83     /**
84      * Returns the {@link FuncNameAndColorGroupEnum} of the given functional name group id.
85      *
86      * @param functionalNameGroupID of the {@link FuncNameAndColorGroupEnum}
87      * @return FunctionalNameAndColorGroupEnum
88      */
89     public static FuncNameAndColorGroupEnum getMode(Short functionalNameGroupID) {
90         return COLOR_GROUPS.get(functionalNameGroupID);
91     }
92
93     private FuncNameAndColorGroupEnum(short functionalColorGroupID, FunctionalColorGroupEnum functionalColorGroup) {
94         this.colorGroup = functionalColorGroupID;
95         this.color = functionalColorGroup;
96     }
97
98     /**
99      * Returns the functional name group id form this Object.
100      *
101      * @return functional name group id
102      */
103     public Short getFunctionalColorGroup() {
104         return colorGroup;
105     }
106
107     /**
108      * Returns the {@link FunctionalColorGroupEnum} form this Object.
109      *
110      * @return FunctionalColorGroupEnum
111      */
112     public FunctionalColorGroupEnum getFunctionalColor() {
113         return color;
114     }
115 }