]> git.basschouten.com Git - openhab-addons.git/blob
cde4c9469e2eef13ca4abfac7f22b3acceebf65f
[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.ecobee.internal.enums;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17
18 import com.google.gson.annotations.SerializedName;
19
20 /**
21  * The {@link PlugState} defines the possible plug states.
22  *
23  * @author Mark Hilbush - Initial contribution
24  */
25 @NonNullByDefault
26 public enum PlugState {
27
28     /**
29      * Sets the plug into the on state for the start/end period specified.
30      * Creates a plug hold in the on state.
31      */
32     @SerializedName("on")
33     ON("on"),
34
35     /**
36      * Sets the plug into the off state for the start/end period specified.
37      * Creates a plug hold in the off state.
38      */
39     @SerializedName("off")
40     OFF("off"),
41
42     /**
43      * Causes the plug to resume its regular program and to follow it. Removes
44      * the currently active plug hold, if no hold is currently running, nothing
45      * happens. No other optional properties are used.
46      */
47     @SerializedName("resume")
48     RESUME("resume");
49
50     private final String state;
51
52     private PlugState(String state) {
53         this.state = state;
54     }
55
56     public static PlugState forValue(@Nullable String v) {
57         if (v != null) {
58             for (PlugState ps : PlugState.values()) {
59                 if (ps.state.equals(v)) {
60                     return ps;
61                 }
62             }
63         }
64         throw new IllegalArgumentException("Invalid plug state: " + v);
65     }
66
67     @Override
68     public String toString() {
69         return this.state;
70     }
71 }