]> git.basschouten.com Git - openhab-addons.git/blob
629d9291f031177d167ea5e6d88dd966604f8972
[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.lutron.internal.radiora.protocol;
14
15 import java.util.ArrayList;
16 import java.util.List;
17
18 import org.eclipse.jdt.annotation.NonNullByDefault;
19 import org.eclipse.jdt.annotation.Nullable;
20 import org.openhab.core.library.types.OnOffType;
21
22 /**
23  * Set Switch Level (SSL)
24  * Turn an individual Switch ON or OFF.
25  *
26  * @author Jeff Lauterbach - Initial Contribution
27  *
28  */
29 @NonNullByDefault
30 public class SetSwitchLevelCommand extends RadioRACommand {
31
32     private int zoneNumber; // 1 to 32
33     private OnOffType state; // ON/OFF
34     private @Nullable Integer delaySec; // 0 to 240 (optional)
35     private int system; // 1 or 2, or 0 for none
36
37     public SetSwitchLevelCommand(int zoneNumber, OnOffType state, int system) {
38         this.zoneNumber = zoneNumber;
39         this.state = state;
40         this.system = system;
41     }
42
43     public void setDelaySeconds(int seconds) {
44         this.delaySec = seconds;
45     }
46
47     @Override
48     public String getCommand() {
49         return "SSL";
50     }
51
52     @Override
53     public List<String> getArgs() {
54         List<String> args = new ArrayList<>();
55         args.add(String.valueOf(zoneNumber));
56         args.add(String.valueOf(state));
57
58         if (delaySec != null) {
59             args.add(String.valueOf(delaySec));
60         }
61
62         if (system == 1 || system == 2) {
63             args.add("S" + system);
64         }
65
66         return args;
67     }
68 }