]> git.basschouten.com Git - openhab-addons.git/blob
10105943fb02dc698946fdc8650c2156c2b39fb0
[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.climate.constants;
14
15 /**
16  * The {@link OperationModes} contains all digitalSTROM heating operation states.
17  *
18  * @author Michael Ochel - Initial contribution
19  * @author Matthias Siegele - Initial contribution
20  */
21 public enum OperationModes {
22
23     OFF((short) 0, "Off"),
24     COMFORT((short) 1, "Comfort"),
25     ECONEMY((short) 2, "Econemy"),
26     NOT_USED((short) 3, "NotUsed"),
27     NIGHT((short) 4, "Night"),
28     HOLLYDAY((short) 5, "Holliday"),
29     COOLING((short) 6, "Cooling"),
30     COOLING_OFF((short) 7, "CoolingOff");
31
32     private final Short id;
33     private final String key;
34
35     private static final OperationModes[] OPERATION_MODES = new OperationModes[OperationModes.values().length];
36
37     static {
38         for (OperationModes operationMode : OperationModes.values()) {
39             OPERATION_MODES[operationMode.id] = operationMode;
40         }
41     }
42
43     /**
44      * Returns the {@link OperationModes} of the given operation mode id.
45      *
46      * @param id of the operation mode
47      * @return operation mode
48      */
49     public static OperationModes getOperationMode(short id) {
50         try {
51             return OPERATION_MODES[id];
52         } catch (IndexOutOfBoundsException e) {
53             return null;
54         }
55     }
56
57     private OperationModes(short id, String key) {
58         this.id = id;
59         this.key = key;
60     }
61
62     /**
63      * Returns the key of the operation mode.
64      *
65      * @return key
66      */
67     public String getKey() {
68         return key;
69     }
70
71     /**
72      * Returns the ID of the operation mode.
73      *
74      * @return ID
75      */
76     public Short getID() {
77         return id;
78     }
79 }