]> git.basschouten.com Git - openhab-addons.git/blob
b9b6be17bebc1df6a77d1ce79820b745440a50d8
[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.Arrays;
16 import java.util.HashMap;
17 import java.util.List;
18 import java.util.Map;
19
20 /**
21  * The {@link FunctionalColorGroupEnum} contains all digitalSTROM functional color groups.
22  *
23  * @author Michael Ochel - Initial contribution
24  * @author Matthias Siegele - Initial contribution
25  * @see <a href="http://developer.digitalstrom.org/Architecture/ds-basics.pdf">ds-basics.pdf,
26  *      "Table 1: digitalSTROM functional groups and their colors", page 9 [04.09.2015]</a>
27  */
28 public enum FunctionalColorGroupEnum {
29     /*
30      * | Number | Name | Color | Function |
31      * --------------------------------------------------------------------------------------
32      * | 1 | Lights | Yellow | Room lights |
33      * | 2 | Blinds | Gray | Blinds or shades outside |
34      * | 12 | Curtains | Gray | Curtains and blinds inside |
35      * | 3 | Heating | Blue | Heating |
36      * | 9 | Cooling | Blue | Cooling |
37      * | 10 | Ventilation | Blue | Ventilation |
38      * | 11 | Window | Blue | Window |
39      * | 48 | Temperature Control | Blue | Single room temperature control |
40      * | 4 | Audio | Cyan | Playing music or radio |
41      * | 5 | Video | Magenta | TV, Video |
42      * | 8 | Joker | Black | Configurable behaviour |
43      * | n/a | Single Device | White | Various, individual per device |
44      * | n/a | Security | Red | Security related functions, Alarms |
45      * | n/a | Access | Green | Access related functions, door bell |
46      *
47      */
48     YELLOW(Arrays.asList((short) 1)),
49     GREY(Arrays.asList((short) 2, (short) 12)),
50     BLUE(Arrays.asList((short) 3, (short) 9, (short) 10, (short) 11, (short) 48)),
51     CYAN(Arrays.asList((short) 4)),
52     MAGENTA(Arrays.asList((short) 5)),
53     BLACK(Arrays.asList((short) 8)),
54     WHITE(Arrays.asList((short) -1)),
55     RED(Arrays.asList((short) -2)),
56     GREEN(Arrays.asList((short) -3));
57
58     private final List<Short> colorGroup;
59
60     static final Map<Short, FunctionalColorGroupEnum> COLOR_GROUPS = new HashMap<>();
61
62     static {
63         for (FunctionalColorGroupEnum colorGroup : FunctionalColorGroupEnum.values()) {
64             for (Short colorGroupID : colorGroup.getFunctionalColorGroup()) {
65                 COLOR_GROUPS.put(colorGroupID, colorGroup);
66             }
67         }
68     }
69
70     /**
71      * Returns true, if contains the given functional color group id in digitalSTROM exits, otherwise false.
72      *
73      * @param functionalColorGroupID to be checked
74      * @return true, if contains
75      */
76     public static boolean containsColorGroup(Short functionalColorGroupID) {
77         return COLOR_GROUPS.keySet().contains(functionalColorGroupID);
78     }
79
80     /**
81      * Returns the {@link FunctionalColorGroupEnum} of the given color id.
82      *
83      * @param functionalColorGroupID of the {@link FunctionalColorGroupEnum}
84      * @return {@link FunctionalColorGroupEnum} of the id
85      */
86     public static FunctionalColorGroupEnum getColorGroup(Short functionalColorGroupID) {
87         return COLOR_GROUPS.get(functionalColorGroupID);
88     }
89
90     private FunctionalColorGroupEnum(List<Short> functionalColorGroupID) {
91         this.colorGroup = functionalColorGroupID;
92     }
93
94     /**
95      * Returns the functional color group id's as {@link List} of this {@link FunctionalColorGroupEnum}.
96      *
97      * @return functional color group id's
98      */
99     public List<Short> getFunctionalColorGroup() {
100         return colorGroup;
101     }
102 }