]> git.basschouten.com Git - openhab-addons.git/blob
0e4e9fe49f36d5b2b373a49819d6da03378079ef
[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.tapocontrol.internal.structures;
14
15 import static org.openhab.binding.tapocontrol.internal.constants.TapoThingConstants.*;
16 import static org.openhab.binding.tapocontrol.internal.helpers.TapoUtils.*;
17
18 import java.awt.Color;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21
22 import com.google.gson.JsonObject;
23
24 /**
25  * Tapo-LightningEffect Structure Class
26  *
27  * @author Christian Wild - Initial contribution
28  */
29 @NonNullByDefault
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 };
38
39     private JsonObject jsonObject = new JsonObject();
40
41     /**
42      * INIT
43      */
44     public TapoLightEffect() {
45         setData();
46     }
47
48     /**
49      * Init DeviceInfo with new Data;
50      * 
51      * @param jso JsonObject new Data
52      */
53     public TapoLightEffect(JsonObject jso) {
54         setData(jso);
55     }
56
57     /**
58      * Set Data (new JsonObject)
59      * 
60      * @param jso JsonObject new Data
61      */
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;
66         } else {
67             jsonObject = new JsonObject();
68         }
69         setData();
70         return this;
71     }
72
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_;
81     }
82
83     /***********************************
84      *
85      * SET VALUES
86      *
87      ************************************/
88
89     public void setEnable(Boolean enable) {
90         this.enable = enable ? 1 : 0;
91     }
92
93     public void setName(String value) {
94         this.name = value;
95     }
96
97     public void setCustom(Boolean enable) {
98         this.custom = enable ? 1 : 0;
99     }
100
101     public void setBrightness(Integer value) {
102         this.brightness = value;
103     }
104
105     public void setColorTempRange() {
106     }
107
108     public void setDisplayColors() {
109     }
110
111     /***********************************
112      *
113      * GET VALUES
114      *
115      ************************************/
116
117     public Integer getEnable() {
118         return this.enable;
119     }
120
121     public String getId() {
122         return this.id;
123     }
124
125     public String getName() {
126         return this.name;
127     }
128
129     public Integer getCustom() {
130         return this.custom;
131     }
132
133     public Integer getBrightness() {
134         return this.brightness;
135     }
136
137     public Integer[] getColorTempRange() {
138         return this.colorTempRange;
139     }
140
141     public Color[] getDisplayColors() {
142         return this.displayColors;
143     }
144
145     @Override
146     public String toString() {
147         return jsonObject.toString();
148     }
149 }