]> git.basschouten.com Git - openhab-addons.git/blob
680354958e5674a947d250abee06beb39259f973
[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.venstarthermostat.internal.dto;
14
15 /**
16  * The {@link VenstarSystemMode} represents the value of the system mode returned
17  * from the REST API.
18  *
19  * @author William Welliver - Initial contribution
20  */
21 public enum VenstarSystemMode {
22     OFF(0, "off", "Off"),
23     HEAT(1, "heat", "Heat"),
24     COOL(2, "cool", "Cool"),
25     AUTO(3, "auto", "Auto");
26
27     private int mode;
28     private String name;
29     private String friendlyName;
30
31     VenstarSystemMode(int mode, String name, String friendlyName) {
32         this.mode = mode;
33         this.name = name;
34         this.friendlyName = friendlyName;
35     }
36
37     public int mode() {
38         return mode;
39     }
40
41     public String modeName() {
42         return name;
43     }
44
45     public String friendlyName() {
46         return friendlyName;
47     }
48
49     public static VenstarSystemMode fromInt(int mode) {
50         for (VenstarSystemMode sm : values()) {
51             if (sm.mode == mode) {
52                 return sm;
53             }
54         }
55
56         throw (new IllegalArgumentException("Invalid system mode " + mode));
57     }
58 }