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.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 (jso.has(DEVICE_PROPERTY_EFFECT)) {
65 this.jsonObject = jso;
67 jsonObject = new JsonObject();
73 private void setData() {
74 this.enable = jsonObjectToInt(jsonObject, PROPERTY_LIGHTNING_EFFECT_ENABLE);
75 this.id = jsonObjectToString(jsonObject, PROPERTY_LIGHTNING_EFFECT_ID);
76 this.name = jsonObjectToString(jsonObject, PROPERTY_LIGHTNING_EFFECT_NAME);
77 this.custom = jsonObjectToInt(jsonObject, PROPERTY_LIGHTNING_EFFECT_CUSTOM); // jsonObjectToBool
78 this.brightness = jsonObjectToInt(jsonObject, PROPERTY_LIGHTNING_EFFECT_BRIGHNTESS);
81 /***********************************
85 ************************************/
87 public void setEnable(Boolean enable) {
88 this.enable = enable ? 1 : 0;
91 public void setName(String value) {
95 public void setCustom(Boolean enable) {
96 this.custom = enable ? 1 : 0;
99 public void setBrightness(Integer value) {
100 this.brightness = value;
103 /***********************************
107 ************************************/
109 public Integer getEnable() {
113 public String getId() {
117 public String getName() {
121 public Integer getCustom() {
125 public Integer getBrightness() {
126 return this.brightness;
129 public Integer[] getColorTempRange() {
130 return this.colorTempRange;
133 public Color[] getDisplayColors() {
134 return this.displayColors;
138 public String toString() {
139 return jsonObject.toString();