]> git.basschouten.com Git - openhab-addons.git/blob
ec0e9e9403503c219f748c063c8a794eada8aa79
[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 VenstarSystemState} represents the value of the system state
17  * returneda from the REST API.
18  *
19  * @author William Welliver - Initial contribution
20  */
21 public enum VenstarSystemState {
22     IDLE(0, "idle", "Idle"),
23     HEATING(1, "heating", "Heating"),
24     COOLING(2, "cooling", "Cooling"),
25     LOCKOUT(3, "lockout", "Lockout"),
26     ERROR(4, "error", "Error");
27
28     private int state;
29     private String name;
30     private String friendlyName;
31
32     VenstarSystemState(int state, String name, String friendlyName) {
33         this.state = state;
34         this.name = name;
35         this.friendlyName = friendlyName;
36     }
37
38     public int state() {
39         return state;
40     }
41
42     public String stateName() {
43         return name;
44     }
45
46     public String friendlyName() {
47         return friendlyName;
48     }
49
50     public static VenstarSystemState fromInt(int state) {
51         for (VenstarSystemState ss : values()) {
52             if (ss.state == state) {
53                 return ss;
54             }
55         }
56
57         throw (new IllegalArgumentException("Invalid system state " + state));
58     }
59 }