2 * Copyright (c) 2010-2022 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.OnOffType;
17 import com.google.gson.annotations.Expose;
18 import com.google.gson.annotations.SerializedName;
21 * Data class for setting the TP-Link Smart Dimmer (HS220) state and retrieving the result.
22 * Only setter methods as the values are set by gson based on the retrieved json.
24 * @author Hilbrand Bouwkamp - Initial contribution
26 public class SetSwitchState implements HasErrorResponse {
28 public static class State extends ErrorResponse {
29 @Expose(deserialize = false)
33 public String toString() {
34 return "state:" + state;
38 public static class Dimmer {
40 private State setSwitchState = new State();
43 public String toString() {
44 return "set_switch_state:{" + setSwitchState + "}";
49 @SerializedName("smartlife.iot.dimmer")
50 private Dimmer dimmer = new Dimmer();
53 public ErrorResponse getErrorResponse() {
54 return dimmer.setSwitchState;
57 public void setSwitchState(OnOffType onOff) {
58 dimmer.setSwitchState.state = onOff == OnOffType.ON ? 1 : 0;
62 public String toString() {
63 return "SetSwitchState {smartlife.iot.dimmer:{" + dimmer + "}";