]> git.basschouten.com Git - openhab-addons.git/blob
b88ba32ef6e7c97f0f660daf676b29945a77d72c
[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 VenstarFanState} represents the state of the fan returned
19  * from the REST API.
20  *
21  * @author Matthew Davies - Initial contribution
22  */
23 @NonNullByDefault
24 public enum VenstarFanState {
25     OFF(0, "off", "Off"),
26     ON(1, "on", "On");
27
28     private int state;
29     private String name;
30     private String friendlyName;
31
32     VenstarFanState(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 VenstarFanState fromInt(int state) throws IllegalArgumentException {
51         for (VenstarFanState fs : values()) {
52             if (fs.state == state) {
53                 return fs;
54             }
55         }
56
57         throw (new IllegalArgumentException("Invalid fan state " + state));
58     }
59 }