]> git.basschouten.com Git - openhab-addons.git/blob
533c8ed9d26f45a4e8a9767ccaccd5168ab006c0
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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 ControlModes} contains all digitalSTROM heating control modes.
17  *
18  * @author Michael Ochel - Initial contribution
19  * @author Matthias Siegele - Initial contribution
20  */
21 public enum ControlModes {
22
23     OFF((short) 0, "off"),
24     PID_CONTROL((short) 1, "pid-control"),
25     ZONE_FOLLOWER((short) 2, "zone-follower"),
26     FIXED_VALUE((short) 3, "fixed-value"),
27     MANUAL((short) 4, "manual");
28
29     private final Short id;
30     private final String key;
31
32     private static final ControlModes[] CONTROL_MODES = new ControlModes[ControlModes.values().length];
33
34     static {
35         for (ControlModes controlMode : ControlModes.values()) {
36             CONTROL_MODES[controlMode.id] = controlMode;
37         }
38     }
39
40     private ControlModes(short id, String key) {
41         this.id = id;
42         this.key = key;
43     }
44
45     /**
46      * Returns the key of the operation mode.
47      *
48      * @return key
49      */
50     public String getKey() {
51         return key;
52     }
53
54     /**
55      * Returns the ID of the operation mode.
56      *
57      * @return ID
58      */
59     public Short getID() {
60         return id;
61     }
62
63     /**
64      * Returns the {@link ControlModes} of the given control mode id.
65      *
66      * @param id of the control mode
67      * @return control mode
68      */
69     public static ControlModes getControlMode(short id) {
70         try {
71             return CONTROL_MODES[id];
72         } catch (IndexOutOfBoundsException e) {
73             return null;
74         }
75     }
76 }