]> git.basschouten.com Git - openhab-addons.git/blob
a2fe140ff352cffb969783220fd196692106b1ce
[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.konnected.internal.gson;
14
15 import static org.openhab.binding.konnected.internal.KonnectedBindingConstants.*;
16
17 import com.google.gson.annotations.SerializedName;
18
19 /**
20  * The {@link KonnectedModuleGson} is responsible to hold
21  * data that models pin information which can be sent to a Konnected Module
22  *
23  * @author Zachary Christiansen - Initial contribution
24  *
25  */
26 public class KonnectedModuleGson {
27
28     private Integer pin;
29     private String zone;
30     private String temp;
31     private String humi;
32     private Integer state;
33     @SerializedName("Auth_Token")
34     private String authToken;
35     private Integer momentary;
36     private Integer pause;
37     private Integer times;
38     @SerializedName("poll_interval")
39     private Integer pollInterval;
40     private String addr;
41
42     public Integer getPin() {
43         return pin;
44     }
45
46     public void setPin(Integer pin) {
47         this.pin = pin;
48     }
49
50     public String getZone() {
51         return zone;
52     }
53
54     public void setZone(String zone) {
55         this.zone = zone;
56     }
57
58     public Integer getPollInterval() {
59         return pollInterval;
60     }
61
62     public void setPollInterval(Integer setPollInterval) {
63         this.pollInterval = setPollInterval;
64     }
65
66     public String getTemp() {
67         return temp;
68     }
69
70     public void setTemp(String setTemp) {
71         this.temp = setTemp;
72     }
73
74     public String getHumi() {
75         return humi;
76     }
77
78     public void setHumi(String setHumi) {
79         this.humi = setHumi;
80     }
81
82     public Integer getState() {
83         return state;
84     }
85
86     public void setState(Integer setState) {
87         this.state = setState;
88     }
89
90     public String getAuthToken() {
91         return authToken;
92     }
93
94     public Integer getMomentary() {
95         return momentary;
96     }
97
98     public void setMomentary(Integer setMomentary) {
99         this.momentary = setMomentary;
100     }
101
102     public Integer getPause() {
103         return pause;
104     }
105
106     public void setPause(Integer setPause) {
107         this.pause = setPause;
108     }
109
110     public Integer getTimes() {
111         return times;
112     }
113
114     public void setTimes(Integer setTimes) {
115         this.times = setTimes;
116     }
117
118     public String getAddr() {
119         return addr;
120     }
121
122     public void setAddr(String setAddr) {
123         this.addr = setAddr;
124     }
125
126     public void setZone(String thingId, String zone) {
127         if (isEsp8266(thingId)) {
128             setPin(ESP8266_ZONE_TO_PIN.get(zone));
129         } else {
130             setZone(zone);
131         }
132     }
133
134     public String getZone(String thingId) {
135         return isEsp8266(thingId) ? ESP8266_PIN_TO_ZONE.get(pin) : getZone();
136     }
137
138     private boolean isEsp8266(String thingId) {
139         return WIFI_MODULE.equals(thingId);
140     }
141 }