]> git.basschouten.com Git - openhab-addons.git/blob
14c8d0551b25ca7ad14c26d27230d8fad13bba99
[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.paradoxalarm.internal.communication.messages;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
18
19 /**
20  * The {@link PartitionCommand} Enum representing the possible commands for a partition with the respective integer
21  * values that are sent as nibbles in the packet.
22  *
23  * @author Konstantin Polihronov - Initial contribution
24  */
25 @NonNullByDefault
26 public enum PartitionCommand {
27     UNKNOWN(0),
28     ARM(2),
29     STAY_ARM(3),
30     INSTANT_ARM(4),
31     FORCE_ARM(5),
32     DISARM(6),
33     BEEP(8);
34
35     private static final Logger logger = LoggerFactory.getLogger(PartitionCommand.class);
36
37     private int command;
38
39     PartitionCommand(int command) {
40         this.command = command;
41     }
42
43     public int getCommand() {
44         return command;
45     }
46
47     public static PartitionCommand parse(String command) {
48         try {
49             return PartitionCommand.valueOf(command);
50         } catch (IllegalArgumentException e) {
51             logger.debug("Unable to parse command={}. Fallback to UNKNOWN.", command);
52             return PartitionCommand.UNKNOWN;
53         }
54     }
55 }