]> git.basschouten.com Git - openhab-addons.git/blob
b2a6f4762d2cef48c9f32dd2b697855f23ee3dcf
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2022 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
21 /**
22  * Set Dimmer Level (SDL)
23  * Set an individual Dimmer’s light level.
24  *
25  * @author Jeff Lauterbach - Initial Contribution
26  *
27  */
28 @NonNullByDefault
29 public class SetDimmerLevelCommand extends RadioRACommand {
30
31     private int zoneNumber; // 1 to 32
32     private int dimmerLevel; // 0 to 100
33     private @Nullable Integer fadeSec; // 0 to 240 (optional)
34     private int system; // 1 or 2, or 0 for none
35
36     public SetDimmerLevelCommand(int zoneNumber, int dimmerLevel, int system) {
37         this.zoneNumber = zoneNumber;
38         this.dimmerLevel = dimmerLevel;
39         this.system = system;
40     }
41
42     public void setFadeSeconds(int seconds) {
43         fadeSec = seconds;
44     }
45
46     @Override
47     public String getCommand() {
48         return "SDL";
49     }
50
51     @Override
52     public List<String> getArgs() {
53         List<String> args = new ArrayList<>();
54         args.add(String.valueOf(zoneNumber));
55         args.add(String.valueOf(dimmerLevel));
56
57         if (fadeSec != null) {
58             args.add(String.valueOf(fadeSec));
59         }
60
61         if (system == 1 || system == 2) {
62             args.add("S" + String.valueOf(system));
63         }
64
65         return args;
66     }
67 }