2 * Copyright (c) 2010-2020 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.nanoleaf.internal.model;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.openhab.core.library.types.OnOffType;
19 import com.google.gson.annotations.SerializedName;
22 * Represents overall state settings of the light panels
24 * @author Martin Raepple - Initial contribution
29 private @Nullable On on;
30 private @Nullable Brightness brightness;
31 private @Nullable Hue hue;
32 @SerializedName("sat")
33 private @Nullable Sat saturation;
35 private @Nullable Ct colorTemperature;
37 private @Nullable String colorMode;
39 public @Nullable On getOn() {
43 public OnOffType getOnOff() {
44 return (on != null && on.getValue()) ? OnOffType.ON : OnOffType.OFF;
47 public void setOn(On on) {
51 public @Nullable Brightness getBrightness() {
55 public void setBrightness(Brightness brightness) {
56 this.brightness = brightness;
59 public @Nullable Hue getHue() {
63 public void setHue(Hue hue) {
67 public @Nullable Sat getSaturation() {
71 public void setSaturation(Sat sat) {
72 this.saturation = sat;
75 public @Nullable Ct getColorTemperature() {
76 return colorTemperature;
79 public void setColorTemperature(Ct ct) {
80 this.colorTemperature = ct;
83 public @Nullable String getColorMode() {
87 public void setColorMode(String colorMode) {
88 this.colorMode = colorMode;
91 public void setState(IntegerState value) {
92 if (value instanceof Brightness) {
93 this.setBrightness((Brightness) value);
94 } else if (value instanceof Hue) {
95 this.setHue((Hue) value);
96 } else if (value instanceof Sat) {
97 this.setSaturation((Sat) value);
98 } else if (value instanceof Ct) {
99 this.setColorTemperature((Ct) value);
103 public void setState(BooleanState value) {
104 if (value instanceof On) {
105 this.setOn((On) value);