]> git.basschouten.com Git - openhab-addons.git/blob
d2bf0f11b1d3dcb157fa87e38c06a9c37c47f8dc
[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.luxom.internal.protocol;
14
15 import java.util.Arrays;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18
19 /**
20  * luxom action
21  * 
22  * @author Kris Jespers - Initial contribution
23  */
24 @NonNullByDefault
25 public enum LuxomAction {
26     HEARTBEAT("*U", false),
27     ACKNOWLEDGE("@1*V", false),
28     TOGGLE("*T", true),
29     PING("*P", true),
30     MODULE_INFORMATION("*!", false),
31     PASSWORD_REQUEST("@1*PW-", false),
32     CLEAR_RESPONSE("@1*C", true),
33     SET_RESPONSE("@1*S", true),
34     DATA_RESPONSE("@1*A", true, true),
35     DATA_BYTE_RESPONSE("@1*Z", false),
36     DATA("*A", true, true),
37     DATA_BYTE("*Z", false),
38     SET("*S", true),
39     CLEAR("*C", true),
40     REQUEST_FOR_INFORMATION("*?", false),
41     INVALID_ACTION("-INVALID-", false); // this is not part of the luxom api, it's for internal use.;
42
43     private final String command;
44     private final boolean hasAddress;
45     private final boolean needsData;
46
47     LuxomAction(String command, boolean hasAddress) {
48         this(command, hasAddress, false);
49     }
50
51     LuxomAction(String command, boolean hasAddress, boolean needsData) {
52         this.command = command;
53         this.hasAddress = hasAddress;
54         this.needsData = needsData;
55     }
56
57     public static LuxomAction of(String command) {
58         return Arrays.stream(LuxomAction.values()).filter(a -> a.getCommand().equals(command)).findFirst()
59                 .orElse(INVALID_ACTION);
60     }
61
62     public String getCommand() {
63         return command;
64     }
65
66     public boolean isHasAddress() {
67         return hasAddress;
68     }
69
70     public boolean isNeedsData() {
71         return needsData;
72     }
73 }