]> git.basschouten.com Git - openhab-addons.git/blob
603100c74bfa39bf9a04869bfa4993364c3794ac
[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 MODE command object
25  *
26  * @author Bob Adair - Initial contribution
27  */
28 @NonNullByDefault
29 public class ModeCommand extends LutronCommandNew {
30     public static final Integer ACTION_STEP = 1;
31
32     private final Integer action;
33     private final @Nullable Integer parameter;
34
35     public ModeCommand(LutronOperation operation, Integer integrationId, Integer action, @Nullable Integer parameter) {
36         super(TargetType.GREENMODE, operation, LutronCommandType.MODE, integrationId);
37         this.action = action;
38         this.parameter = parameter;
39     }
40
41     @Override
42     public String lipCommand() {
43         StringBuilder builder = new StringBuilder().append(operation).append(commandType);
44         builder.append(',').append(integrationId);
45         builder.append(',').append(action);
46         if (parameter != null) {
47             builder.append(',').append(parameter);
48         }
49
50         return builder.toString();
51     }
52
53     @Override
54     public @Nullable LeapCommand leapCommand(LeapBridgeHandler bridgeHandler, @Nullable Integer leapZone) {
55         return null;
56     }
57
58     @Override
59     public String toString() {
60         return lipCommand();
61     }
62 }