]> git.basschouten.com Git - openhab-addons.git/blob
61bb286e69a5338a25b12d404bacce8c4e4a5be6
[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.protocol;
14
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.binding.lutron.internal.handler.LeapBridgeHandler;
18 import org.openhab.binding.lutron.internal.protocol.leap.LeapCommand;
19 import org.openhab.binding.lutron.internal.protocol.lip.LutronCommandType;
20 import org.openhab.binding.lutron.internal.protocol.lip.LutronOperation;
21 import org.openhab.binding.lutron.internal.protocol.lip.TargetType;
22
23 /**
24  * Lutron SYSVAR command object
25  *
26  * @author Bob Adair - Initial contribution
27  */
28 @NonNullByDefault
29 public class SysvarCommand extends LutronCommandNew {
30     public static final Integer ACTION_GETSETSYSVAR = 1;
31
32     private final Integer action;
33     private final @Nullable Object parameter;
34
35     /**
36      * SysvarCommand constructor
37      *
38      * @param targetType
39      * @param operation
40      * @param integrationId
41      * @param action
42      * @param parameter
43      */
44     public SysvarCommand(LutronOperation operation, Integer integrationId, Integer action, @Nullable Object parameter) {
45         super(TargetType.SYSVAR, operation, LutronCommandType.SYSVAR, integrationId);
46         this.action = action;
47         this.parameter = parameter;
48     }
49
50     @Override
51     public String lipCommand() {
52         StringBuilder builder = new StringBuilder().append(operation).append(commandType);
53         builder.append(',').append(integrationId);
54         builder.append(',').append(action);
55         if (parameter != null) {
56             builder.append(',').append(parameter);
57         }
58
59         return builder.toString();
60     }
61
62     @Override
63     public @Nullable LeapCommand leapCommand(LeapBridgeHandler bridgeHandler, @Nullable Integer leapZone) {
64         return null; // No equivalent LEAP command
65     }
66
67     @Override
68     public String toString() {
69         return lipCommand();
70     }
71 }