2 * Copyright (c) 2010-2022 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.miio.internal.basic;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
18 import com.google.gson.JsonArray;
19 import com.google.gson.annotations.Expose;
20 import com.google.gson.annotations.SerializedName;
23 * Mapping actions from json
25 * @author Marcel Verpaalen - Initial contribution
28 public class MiIoDeviceAction {
30 @SerializedName("command")
32 private @Nullable String command;
33 @SerializedName("parameterType")
35 private CommandParameterType commandParameterType = CommandParameterType.EMPTY;
36 @SerializedName("parameters")
38 private @Nullable JsonArray parameters;
39 @SerializedName("siid")
41 private @Nullable Integer siid;
42 @SerializedName("aiid")
44 private @Nullable Integer aiid;
45 @SerializedName("condition")
47 private @Nullable MiIoDeviceActionCondition condition;
49 public JsonArray getParameters() {
50 final @Nullable JsonArray parameter = this.parameters;
51 return parameter != null ? parameter : new JsonArray();
54 public void setParameters(JsonArray parameters) {
55 this.parameters = parameters;
58 public String getCommand() {
59 final @Nullable String command = this.command;
60 return command != null ? command : "";
63 public void setCommand(String command) {
64 this.command = command;
67 public CommandParameterType getparameterType() {
68 return commandParameterType;
71 public void setparameterType(CommandParameterType type) {
72 this.commandParameterType = type;
75 public void setparameterType(String type) {
76 this.commandParameterType = org.openhab.binding.miio.internal.basic.CommandParameterType.fromString(type);
79 public int getSiid() {
80 final Integer siid = this.siid;
82 return siid.intValue();
88 public void setSiid(Integer siid) {
92 public int getAiid() {
93 final Integer aiid = this.aiid;
95 return aiid.intValue();
101 public void setAiid(Integer aiid) {
105 public boolean isMiOtAction() {
106 return aiid != null && siid != null && (getAiid() != 0 || getSiid() != 0);
109 public @Nullable MiIoDeviceActionCondition getCondition() {
113 public void setCondition(@Nullable MiIoDeviceActionCondition condition) {
114 this.condition = condition;
118 public String toString() {
119 return "MiIoDeviceAction [command=" + command + ", commandParameterType=" + commandParameterType
120 + (parameters != null ? ", parameters=" + getParameters().toString() : "") + "]";