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