]> git.basschouten.com Git - openhab-addons.git/blob
0885a06caa84aade1baccee2ddb57291324791e2
[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.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 Matthew Davies - Initial contribution
20  */
21 public enum VenstarAwayMode {
22     HOME(0, "home", "Home"),
23     AWAY(1, "away", "Away");
24
25     private int mode;
26     private String name;
27     private String friendlyName;
28
29     VenstarAwayMode(int mode, String name, String friendlyName) {
30         this.mode = mode;
31         this.name = name;
32         this.friendlyName = friendlyName;
33     }
34
35     public int mode() {
36         return mode;
37     }
38
39     public String modeName() {
40         return name;
41     }
42
43     public String friendlyName() {
44         return friendlyName;
45     }
46
47     public static VenstarAwayMode fromInt(int mode) throws IllegalArgumentException {
48         for (VenstarAwayMode am : values()) {
49             if (am.mode == mode) {
50                 return am;
51             }
52         }
53
54         throw (new IllegalArgumentException("Invalid away mode " + mode));
55     }
56 }