]> git.basschouten.com Git - openhab-addons.git/blob
412838bf8507b570b0dcec31e478e6d1f0a18a9d
[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.mielecloud.internal.webservice.api.json;
14
15 import java.util.Collections;
16 import java.util.HashMap;
17 import java.util.Map;
18 import java.util.Optional;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21
22 /**
23  * Represents the Miele device state.
24  *
25  * @author Roland Edelhoff - Initial contribution
26  */
27 @NonNullByDefault
28 public enum StateType {
29     OFF(1),
30     ON(2),
31     PROGRAMMED(3),
32     PROGRAMMED_WAITING_TO_START(4),
33     RUNNING(5),
34     PAUSE(6),
35     END_PROGRAMMED(7),
36     FAILURE(8),
37     PROGRAMME_INTERRUPTED(9),
38     IDLE(10),
39     RINSE_HOLD(11),
40     SERVICE(12),
41     SUPERFREEZING(13),
42     SUPERCOOLING(14),
43     SUPERHEATING(15),
44     SUPERCOOLING_SUPERFREEZING(146),
45     NOT_CONNECTED(255);
46
47     private static final Map<Integer, StateType> STATE_TYPE_BY_CODE;
48
49     static {
50         Map<Integer, StateType> stateTypeByCode = new HashMap<>();
51         for (StateType stateType : values()) {
52             stateTypeByCode.put(stateType.code, stateType);
53         }
54         STATE_TYPE_BY_CODE = Collections.unmodifiableMap(stateTypeByCode);
55     }
56
57     private final int code;
58
59     private StateType(int code) {
60         this.code = code;
61     }
62
63     public int getCode() {
64         return code;
65     }
66
67     public static Optional<StateType> fromCode(int code) {
68         return Optional.ofNullable(STATE_TYPE_BY_CODE.get(code));
69     }
70 }