]> git.basschouten.com Git - openhab-addons.git/blob
e15b338c42df82fca6d0beb82c1bdbe97b17a0e5
[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.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     WIRELESSHDSTANDBY(0x07),
36     UNKNOWN(0xFF);
37
38     private final int value;
39
40     PowerStatus(int value) {
41         this.value = value;
42     }
43
44     public static PowerStatus forValue(int value) {
45         try {
46             return Arrays.stream(values()).filter(e -> e.value == value).findFirst().get();
47         } catch (NoSuchElementException e) {
48             return UNKNOWN;
49         }
50     }
51
52     public int toInt() {
53         return value;
54     }
55 }