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