2 * Copyright (c) 2010-2024 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.tapocontrol.internal.structures;
15 import static org.openhab.binding.tapocontrol.internal.constants.TapoThingConstants.*;
16 import static org.openhab.binding.tapocontrol.internal.helpers.TapoUtils.*;
18 import java.awt.Color;
20 import org.eclipse.jdt.annotation.NonNullByDefault;
22 import com.google.gson.JsonObject;
25 * Tapo-LightningEffect Structure Class
27 * @author Christian Wild - Initial contribution
30 public class TapoLightEffect {
31 private Integer enable = 0;
32 private String id = "";
33 private String name = "";
34 private Integer custom = 0;
35 private Integer brightness = 0;
36 private Integer[] colorTempRange = { 9000, 9000 }; // :[9000,9000]
37 private Color[] displayColors = { Color.WHITE };
39 private JsonObject jsonObject = new JsonObject();
44 public TapoLightEffect() {
49 * Init DeviceInfo with new Data;
51 * @param jso JsonObject new Data
53 public TapoLightEffect(JsonObject jso) {
58 * Set Data (new JsonObject)
60 * @param jso JsonObject new Data
62 public TapoLightEffect setData(JsonObject jso) {
63 /* create empty jsonObject to set efault values if has no lighning effect */
64 if (jsonObject.has(JSON_KEY_LIGHTNING_EFFECT)) {
65 this.jsonObject = jso;
67 jsonObject = new JsonObject();
73 private void setData() {
74 this.enable = jsonObjectToInt(jsonObject, JSON_KEY_LIGHTNING_EFFECT_ENABLE);
75 this.id = jsonObjectToString(jsonObject, JSON_KEY_LIGHTNING_EFFECT_ID);
76 this.name = jsonObjectToString(jsonObject, JSON_KEY_LIGHTNING_EFFECT_NAME);
77 this.custom = jsonObjectToInt(jsonObject, JSON_KEY_LIGHTNING_EFFECT_CUSTOM); // jsonObjectToBool
78 this.brightness = jsonObjectToInt(jsonObject, JSON_KEY_LIGHTNING_EFFECT_BRIGHNTESS);
79 // this.color_temp_range = { 9000, 9000 }; PROPERTY_LIGHNTING_ //:[9000,9000]
80 // this.displayColors[] PROPERTY_LIGHNTING_;
83 /***********************************
87 ************************************/
89 public void setEnable(Boolean enable) {
90 this.enable = enable ? 1 : 0;
93 public void setName(String value) {
97 public void setCustom(Boolean enable) {
98 this.custom = enable ? 1 : 0;
101 public void setBrightness(Integer value) {
102 this.brightness = value;
105 public void setColorTempRange() {
108 public void setDisplayColors() {
111 /***********************************
115 ************************************/
117 public Integer getEnable() {
121 public String getId() {
125 public String getName() {
129 public Integer getCustom() {
133 public Integer getBrightness() {
134 return this.brightness;
137 public Integer[] getColorTempRange() {
138 return this.colorTempRange;
141 public Color[] getDisplayColors() {
142 return this.displayColors;
146 public String toString() {
147 return jsonObject.toString();