2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.lutron.internal.protocol;
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;
24 * Generic LIP command for use inside bridge handler
26 * @author Bob Adair - Initial contribution
29 public class LIPCommand extends LutronCommandNew {
30 private final Object[] parameters;
32 public LIPCommand(TargetType targetType, LutronOperation operation, LutronCommandType CommandType,
33 @Nullable Integer integrationId, Object... parameters) {
34 super(targetType, operation, CommandType, integrationId);
35 this.parameters = parameters;
39 public String lipCommand() {
40 StringBuilder builder = new StringBuilder().append(operation).append(commandType);
41 if (integrationId != null) {
42 builder.append(',').append(integrationId);
44 if (parameters != null) { // This CAN be null
45 for (Object parameter : parameters) {
46 builder.append(',').append(parameter);
50 return builder.toString();
54 public @Nullable LeapCommand leapCommand(LeapBridgeHandler bridgeHandler, @Nullable Integer leapZone) {
59 public String toString() {
63 public int getNumberParameter(int position) {
64 if (parameters.length > position && parameters[position] instanceof Number) {
65 Number num = (Number) parameters[position];
66 return num.intValue();
68 throw new IllegalArgumentException("Invalid command parameter");