]> git.basschouten.com Git - openhab-addons.git/blob
5d07fd63932c77730147c1454cb378603d09c3d7
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2021 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.lutron.internal.radiora.protocol;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 /**
19  * Button Press (BP) Command.
20  * Trigger a Phantom Button Press on the RadioRA Serial Device.
21  *
22  * @author Jeff Lauterbach - Initial Contribution
23  *
24  */
25 public class ButtonPressCommand extends RadioRACommand {
26
27     public enum ButtonState {
28         OFF,
29         ON,
30         TOG
31     }
32
33     private int buttonNumber; // 1 to 15, 16 ALL ON, 17 ALL OFF
34     private ButtonState state; // ON/OFF/TOG
35     private Integer fadeSec; // 0 to 240 (optional)
36
37     public ButtonPressCommand(int buttonNumber, ButtonState state) {
38         this.buttonNumber = buttonNumber;
39         this.state = state;
40     }
41
42     public void setFadeSeconds(int seconds) {
43         this.fadeSec = seconds;
44     }
45
46     @Override
47     public String getCommand() {
48         return "BP";
49     }
50
51     @Override
52     public List<String> getArgs() {
53         List<String> args = new ArrayList<>();
54         args.add(String.valueOf(buttonNumber));
55         args.add(String.valueOf(state));
56
57         if (fadeSec != null) {
58             args.add(String.valueOf(fadeSec));
59         }
60
61         return args;
62     }
63 }