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.tplinksmarthome.internal.model;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.openhab.core.library.types.OnOffType;
18 import com.google.gson.annotations.SerializedName;
21 * Data class to setting different kind of states on Smart Home light bulbs.
22 * Only setter methods as the object is only used to send values.
24 * @author Hilbrand Bouwkamp - Initial contribution
26 public class TransitionLightState {
29 * Color sets hue, saturation and brightness.
30 * color temperature present to send with default 0 value to bulb.
32 public static class LightStateColor extends LightStateBrightness {
33 private int colorTemp;
35 private int saturation;
37 public void setHue(int hue) {
41 public void setSaturation(int saturation) {
42 this.saturation = saturation;
46 public String toString() {
47 return "colorTemp" + colorTemp + ", hue:" + hue + ", saturation:" + saturation + ", " + super.toString();
52 * Color Temperature doesn't set brightness therefore separate class.
53 * hue and saturation present to send with default 0 value to bulb.
55 public static class LightStateColorTemperature extends LightOnOff {
56 private int colorTemp;
58 private int saturation;
60 public void setColorTemperature(int colorTemp) {
61 this.colorTemp = colorTemp;
65 public String toString() {
66 return "colorTemp" + colorTemp + ", hue:" + hue + ", saturation:" + saturation + ", " + super.toString();
70 public static class LightStateBrightness extends LightOnOff {
71 private int brightness;
73 public void setBrightness(int brightness) {
74 this.brightness = brightness;
78 public String toString() {
79 return "brightness:" + brightness + ", " + super.toString();
83 public static class LightOnOff {
85 private int ignoreDefault = 1;
86 private String mode = "normal";
87 private int transitionPeriod;
89 public void setOnOff(OnOffType onOff) {
90 this.onOff = onOff == OnOffType.ON ? 1 : 0;
93 public void setTransitionPeriod(int transitionPeriod) {
94 this.transitionPeriod = transitionPeriod;
98 public String toString() {
99 return "onOff:" + onOff + ", ignoreDefault:" + ignoreDefault + ", mode:" + mode + ", transitionPeriod:"
104 public static class LightingService {
105 private LightOnOff transitionLightState;
108 public String toString() {
109 return "transitionLightState:{" + transitionLightState + "}";
114 @SerializedName("smartlife.iot.smartbulb.lightingservice")
115 private LightingService service = new LightingService();
117 public void setLightState(LightOnOff lightState) {
118 service.transitionLightState = lightState;
122 public String toString() {
123 return "TransitionLightState {service:{" + service + "}";