]> git.basschouten.com Git - openhab-addons.git/blob
d17b49cf1d623213383cc2cccef00b78f35fe36a
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.tplinksmarthome.internal.model;
14
15 import org.openhab.core.library.types.OnOffType;
16
17 import com.google.gson.annotations.Expose;
18
19 /**
20  * Data class to set the led of a Smart Home device on or off.
21  * Only setter methods as the object is only used to send values.
22  *
23  * @author Hilbrand Bouwkamp - Initial contribution
24  */
25 public class SetLedOff extends ContextState implements HasErrorResponse {
26
27     public static class LedOff extends ErrorResponse {
28         @Expose
29         private int off;
30
31         public void setOff(int off) {
32             this.off = off;
33         }
34
35         @Override
36         public String toString() {
37             return "off:" + off + super.toString();
38         }
39     }
40
41     public static class System {
42         @Expose
43         private LedOff setLedOff = new LedOff();
44
45         @Override
46         public String toString() {
47             return "set_led_off:{" + setLedOff + "}";
48         }
49     }
50
51     @Expose
52     private System system = new System();
53
54     @Override
55     public ErrorResponse getErrorResponse() {
56         return system.setLedOff;
57     }
58
59     public void setLed(OnOffType onOff) {
60         system.setLedOff.setOff(onOff == OnOffType.OFF ? 1 : 0);
61     }
62
63     @Override
64     public String toString() {
65         return "SetLedOff {system:{" + system + "}";
66     }
67 }