]> git.basschouten.com Git - openhab-addons.git/blob
6c3a59b5e94aedecb397dd6497fb06ba69fdf18f
[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 TIMECLOCK command object
25  *
26  * @author Bob Adair - Initial contribution
27  */
28 @NonNullByDefault
29 public class TimeclockCommand extends LutronCommandNew {
30     public static final Integer ACTION_CLOCKMODE = 1;
31     public static final Integer ACTION_SUNRISE = 2;
32     public static final Integer ACTION_SUNSET = 3;
33     public static final Integer ACTION_EXECEVENT = 5;
34     public static final Integer ACTION_SETEVENT = 6;
35     public static final Integer EVENT_ENABLE = 1;
36     public static final Integer EVENT_DISABLE = 2;
37
38     private final Integer action;
39     private final @Nullable Object parameter;
40     private final @Nullable Boolean enable;
41
42     /**
43      * TimeclockCommand constructor
44      *
45      * @param operation
46      * @param integrationId
47      * @param action
48      * @param parameter
49      * @param enable true = enable, false = disable
50      */
51     public TimeclockCommand(LutronOperation operation, Integer integrationId, Integer action,
52             @Nullable Object parameter, @Nullable Boolean enable) {
53         super(TargetType.TIMECLOCK, operation, LutronCommandType.TIMECLOCK, integrationId);
54         this.action = action;
55         this.parameter = parameter;
56         this.enable = enable;
57     }
58
59     @Override
60     public String lipCommand() {
61         StringBuilder builder = new StringBuilder().append(operation).append(commandType);
62         builder.append(',').append(integrationId);
63         builder.append(',').append(action);
64         if (parameter != null) {
65             builder.append(',').append(parameter);
66         }
67         if (enable != null) {
68             builder.append(',');
69             builder.append((enable) ? '1' : '2');
70         }
71
72         return builder.toString();
73     }
74
75     @Override
76     public @Nullable LeapCommand leapCommand(LeapBridgeHandler bridgeHandler, @Nullable Integer leapZone) {
77         return null;
78     }
79
80     @Override
81     public String toString() {
82         return lipCommand();
83     }
84 }