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.openhab.core.library.types.DecimalType;
16 import org.openhab.core.library.types.OnOffType;
17 import org.openhab.core.library.types.PercentType;
20 * Data class for reading the retrieved state of a Smart Home light bulb.
21 * Mostly only getter methods as the values are set by gson based on the retrieved json.
23 * @author Hilbrand Bouwkamp - Initial contribution
25 public class LightState extends ErrorResponse {
27 private int brightness;
28 private int colorTemp;
30 private int ignoreDefault;
33 private int saturation;
35 public PercentType getBrightness() {
36 return onOff > 0 ? new PercentType(brightness) : PercentType.ZERO;
39 public int getColorTemp() {
43 public DecimalType getHue() {
44 return new DecimalType(hue);
47 public int getIgnoreDefault() {
51 public String getMode() {
55 public OnOffType getOnOff() {
56 return OnOffType.from(onOff == 1);
59 public PercentType getSaturation() {
60 return new PercentType(saturation);
63 public void setOnOff(OnOffType onOff) {
64 this.onOff = onOff == OnOffType.ON ? 1 : 0;
68 public String toString() {
69 return "brightness:" + brightness + ", color_temp:" + colorTemp + ", hue:" + hue + ", ignore_default:"
70 + ignoreDefault + ", mode:" + mode + ", on_off:" + onOff + ", saturation:" + saturation