]> git.basschouten.com Git - openhab-addons.git/blob
8922ebf92e4461b9a1c7096b47aaad6bf7819193
[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.epsonprojector.internal.enums;
14
15 import java.util.Arrays;
16 import java.util.NoSuchElementException;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19
20 /**
21  * Valid values for PowerStatus.
22  *
23  * @author Pauli Anttila - Initial contribution
24  * @author Yannick Schaus - Refactoring
25  * @author Michael Lobstein - Improvements for OH3
26  */
27 @NonNullByDefault
28 public enum PowerStatus {
29     STANDBY(0x00),
30     ON(0x01),
31     WARMUP(0x02),
32     COOLDOWN(0x03),
33     STANDBYNETWORKON(0x04),
34     ABNORMALSTANDBY(0x05),
35     UNKNOWN(0xFF);
36
37     private final int value;
38
39     PowerStatus(int value) {
40         this.value = value;
41     }
42
43     public static PowerStatus forValue(int value) {
44         try {
45             return Arrays.stream(values()).filter(e -> e.value == value).findFirst().get();
46         } catch (NoSuchElementException e) {
47             return UNKNOWN;
48         }
49     }
50
51     public int toInt() {
52         return value;
53     }
54 }