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.hue.internal.api.dto.clip1;
15 import java.util.Arrays;
18 * Current state of light.
20 * @author Q42 - Initial contribution
21 * @author Denis Dudnik - moved Jue library source code inside the smarthome Hue binding
22 * @author Laurent Garnier - add few methods to update the object
32 private String effect;
33 public String colormode;
34 private boolean reachable;
40 * Color modes of a light.
42 public enum ColorMode {
44 * CIE color space coordinates
54 * Color temperature in mired
60 * Alert modes of a light.
62 public enum AlertMode {
64 * Light is not performing alert effect
69 * Light is performing one breathe cycle
74 * Light is performing breathe cycles for 30 seconds (unless cancelled)
80 * Effects possible for a light.
89 * Cycle through all hues with current saturation and brightness
95 * Returns the on state.
97 * @return true if the light is on, false if it isn't
99 public boolean isOn() {
103 public void setOn(boolean on) {
108 * Returns the brightness.
112 public int getBrightness() {
116 public void setBri(int bri) {
125 public int getHue() {
129 public void setHue(int hue) {
134 * Returns the saturation.
138 public int getSaturation() {
142 public void setSaturation(int sat) {
147 * Returns the coordinates in CIE color space.
149 * @return cie color spaces coordinates
151 public float[] getXY() {
155 public void setXY(float[] xy) {
160 * Returns the color temperature.
162 * @return color temperature
164 public int getColorTemperature() {
168 public void setColorTemperature(int ct) {
173 * Returns the last alert mode set.
174 * Future firmware updates may change this to actually report the current alert mode.
176 * @return last alert mode
178 public AlertMode getAlertMode() {
182 return AlertMode.valueOf(alert.toUpperCase());
186 * Returns the current color mode.
188 * @return current color mode
190 public ColorMode getColorMode() {
191 if (colormode == null) {
194 return ColorMode.valueOf(colormode.toUpperCase());
197 public void setColormode(ColorMode colormode) {
198 this.colormode = colormode.name();
202 * Returns the current active effect.
204 * @return current active effect
206 public Effect getEffect() {
207 if (effect == null) {
210 return Effect.valueOf(effect.toUpperCase());
214 * Returns reachability.
216 * @return true if reachable, false if it isn't
218 public boolean isReachable() {
223 public int hashCode() {
224 final int prime = 31;
226 result = prime * result + ((alert == null) ? 0 : alert.hashCode());
227 result = prime * result + bri;
228 result = prime * result + ((colormode == null) ? 0 : colormode.hashCode());
229 result = prime * result + ct;
230 result = prime * result + ((effect == null) ? 0 : effect.hashCode());
231 result = prime * result + hue;
232 result = prime * result + (on ? 1231 : 1237);
233 result = prime * result + (reachable ? 1231 : 1237);
234 result = prime * result + sat;
235 result = prime * result + Arrays.hashCode(xy);
240 public boolean equals(Object obj) {
247 if (getClass() != obj.getClass()) {
250 State other = (State) obj;
252 if (other.alert != null) {
255 } else if (!alert.equals(other.alert)) {
258 if (bri != other.bri) {
261 if (colormode == null) {
262 if (other.colormode != null) {
265 } else if (!colormode.equals(other.colormode)) {
268 if (ct != other.ct) {
271 if (effect == null) {
272 if (other.effect != null) {
275 } else if (!effect.equals(other.effect)) {
278 if (hue != other.hue) {
281 if (on != other.on) {
284 if (reachable != other.reachable) {
287 if (sat != other.sat) {
290 return Arrays.equals(xy, other.xy);