]> git.basschouten.com Git - openhab-addons.git/blob
ef49bcb6f3ce5f2d86a4cca7bbbf2872e6812e46
[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.elerotransmitterstick.internal.stick;
14
15 /**
16  * @author Volker Bier - Initial contribution
17  */
18 public enum ResponseStatus {
19     NO_INFORMATION((byte) 0x00),
20     TOP((byte) 0x01),
21     BOTTOM((byte) 0x02),
22     INTERMEDIATE((byte) 0x03),
23     VENTILATION((byte) 0x04),
24     BLOCKING((byte) 0x05),
25     OVERHEATED((byte) 0x06),
26     TIMEOUT((byte) 0x07),
27     START_MOVE_UP((byte) 0x08),
28     START_MOVE_DOWN((byte) 0x09),
29     MOVING_UP((byte) 0x0a),
30     MOVING_DOWN((byte) 0x0b),
31     STOPPED((byte) 0x0d),
32     TOP_TILT((byte) 0x0e),
33     BOTTOM_INTERMEDIATE((byte) 0x0f),
34     SWITCHED_OFF((byte) 0x10),
35     SWITCHED_ON((byte) 0x11);
36
37     public static final byte EASY_CONFIRM = (byte) 0x4B;
38     public static final byte EASY_ACK = (byte) 0x4D;
39
40     private byte statusByte;
41
42     private ResponseStatus(byte statusByte) {
43         this.statusByte = statusByte;
44     }
45
46     public static ResponseStatus getFor(byte statusByte) {
47         if (statusByte <= MOVING_DOWN.statusByte) {
48             return ResponseStatus.values()[statusByte];
49         }
50         return ResponseStatus.values()[statusByte - 1];
51     }
52
53     public static int getPercentageFor(ResponseStatus status) {
54         switch (status) {
55             case BOTTOM:
56                 return 100;
57             case NO_INFORMATION:
58                 return -1;
59             case TOP:
60                 return 0;
61             case INTERMEDIATE:
62                 return 25;
63             case VENTILATION:
64                 return 75;
65             default:
66                 return 50;
67         }
68     }
69 }