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.OnOffType;
17 import com.google.gson.annotations.Expose;
20 * Data class for setting the TP-Link Smart Plug state and retrieving the result.
21 * Only setter methods as the values are set by gson based on the retrieved json.
23 * @author Hilbrand Bouwkamp - Initial contribution
25 public class SetRelayState extends ContextState implements HasErrorResponse {
27 public static class RelayState extends ErrorResponse {
28 @Expose(deserialize = false)
32 public String toString() {
33 return "state:" + state;
37 public static class System {
39 private RelayState setRelayState = new RelayState();
41 public void setRelayState(OnOffType onOff) {
42 setRelayState.state = onOff == OnOffType.ON ? 1 : 0;
46 public String toString() {
47 return "set_relay_state:{" + setRelayState + "}";
52 private System system = new System();
55 public ErrorResponse getErrorResponse() {
56 return system.setRelayState;
59 public void setRelayState(OnOffType onOff) {
60 system.setRelayState(onOff);
64 public String toString() {
65 return "SetRelayState {system:{" + system + "}";