]> git.basschouten.com Git - openhab-addons.git/blob
82c6860474fd5d9afcc5195efdf18e50e72b8ed3
[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.eclipse.jdt.annotation.NonNullByDefault;
16
17 import com.google.gson.annotations.Expose;
18 import com.google.gson.annotations.SerializedName;
19
20 /**
21  * Data class to set the Brightness of a Smart Home dimmer (HS220).
22  * Setter methods for data and getter for error response.
23  *
24  * @author Hilbrand Bouwkamp - Initial contribution
25  */
26 @NonNullByDefault
27 public class SetBrightness implements HasErrorResponse {
28
29     public static class Brightness extends ErrorResponse {
30         @Expose(deserialize = false)
31         private int brightness;
32
33         @Override
34         public String toString() {
35             return "brightness:" + brightness + super.toString();
36         }
37     }
38
39     public static class Dimmer {
40         @Expose
41         private Brightness setBrightness = new Brightness();
42
43         @Override
44         public String toString() {
45             return "set_brightness:{" + setBrightness + "}";
46         }
47     }
48
49     @Expose
50     @SerializedName("smartlife.iot.dimmer")
51     private Dimmer dimmer = new Dimmer();
52
53     @Override
54     public ErrorResponse getErrorResponse() {
55         return dimmer.setBrightness;
56     }
57
58     public void setBrightness(int brightness) {
59         dimmer.setBrightness.brightness = brightness;
60     }
61
62     @Override
63     public String toString() {
64         return "smartlife.iot.dimmer:{" + dimmer + "}";
65     }
66 }