]> git.basschouten.com Git - openhab-addons.git/blob
43b30eaec4cb10dc18aaccb24aba138413202edb
[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.digitalstrom.internal.lib.climate.jsonresponsecontainer.impl;
14
15 import org.openhab.binding.digitalstrom.internal.lib.climate.jsonresponsecontainer.BaseTemperatureControl;
16 import org.openhab.binding.digitalstrom.internal.lib.serverconnection.constants.JSONApiResponseKeysEnum;
17
18 import com.google.gson.JsonObject;
19
20 /**
21  * The {@link TemperatureControlConfig} acts as container for the digitalSTROM json-method
22  * <i>getTemperatureControlConfig</i>. So the {@link TemperatureControlConfig} contains all heating control
23  * configurations of a zone.
24  *
25  * @author Michael Ochel - Initial contribution
26  * @author Matthias Siegele - Initial contribution
27  */
28 public class TemperatureControlConfig extends BaseTemperatureControl {
29
30     private Integer referenceZone;
31     private Float ctrlOffset;
32     private Float manualValue;
33     private Float emergencyValue;
34     private Float ctrlKp;
35     private Float ctrlTs;
36     private Float ctrlTi;
37     private Float ctrlKd;
38     private Float ctrlImin;
39     private Float ctrlImax;
40     private Float ctrlYmin;
41     private Float ctrlYmax;
42     private Boolean ctrlAntiWindUp;
43     private Boolean ctrlKeepFloorWarm;
44
45     /**
46      * Creates a new {@link TemperatureControlConfig} through the {@link JsonObject} which will be returned by an
47      * apartment call.
48      *
49      * @param jObject must not be null
50      */
51     public TemperatureControlConfig(JsonObject jObject) {
52         super(jObject);
53         init(jObject);
54     }
55
56     /**
57      * Creates a new {@link TemperatureControlConfig} through the {@link JsonObject} which will be returned by a zone
58      * call.<br>
59      * Because of zone calls does not include a zoneID or zoneName in the json response, the zoneID and zoneName have to
60      * be handed over the constructor.
61      *
62      * @param jObject must not be null
63      * @param zoneID must not be null
64      * @param zoneName can be null
65      */
66     public TemperatureControlConfig(JsonObject jObject, Integer zoneID, String zoneName) {
67         super(jObject, zoneID, zoneName);
68         init(jObject);
69     }
70
71     private void init(JsonObject jObject) {
72         if (isNotSetOff()) {
73             if (controlMode == 1) {
74                 if (jObject.get(JSONApiResponseKeysEnum.EMERGENCY_VALUE.getKey()) != null) {
75                     this.emergencyValue = jObject.get(JSONApiResponseKeysEnum.EMERGENCY_VALUE.getKey()).getAsFloat();
76                 }
77                 if (jObject.get(JSONApiResponseKeysEnum.CTRL_KP.getKey()) != null) {
78                     this.ctrlKp = jObject.get(JSONApiResponseKeysEnum.CTRL_KP.getKey()).getAsFloat();
79                 }
80                 if (jObject.get(JSONApiResponseKeysEnum.CTRL_TS.getKey()) != null) {
81                     this.ctrlTs = jObject.get(JSONApiResponseKeysEnum.CTRL_TS.getKey()).getAsFloat();
82                 }
83                 if (jObject.get(JSONApiResponseKeysEnum.CTRL_TI.getKey()) != null) {
84                     this.ctrlTi = jObject.get(JSONApiResponseKeysEnum.CTRL_TI.getKey()).getAsFloat();
85                 }
86                 if (jObject.get(JSONApiResponseKeysEnum.CTRL_KD.getKey()) != null) {
87                     this.ctrlKd = jObject.get(JSONApiResponseKeysEnum.CTRL_KD.getKey()).getAsFloat();
88                 }
89                 if (jObject.get(JSONApiResponseKeysEnum.CTRL_MIN.getKey()) != null) {
90                     this.ctrlImin = jObject.get(JSONApiResponseKeysEnum.CTRL_MIN.getKey()).getAsFloat();
91                 }
92                 if (jObject.get(JSONApiResponseKeysEnum.CTRL_MAX.getKey()) != null) {
93                     this.ctrlImax = jObject.get(JSONApiResponseKeysEnum.CTRL_MAX.getKey()).getAsFloat();
94                 }
95                 if (jObject.get(JSONApiResponseKeysEnum.CTRL_Y_MIN.getKey()) != null) {
96                     this.ctrlYmin = jObject.get(JSONApiResponseKeysEnum.CTRL_Y_MIN.getKey()).getAsFloat();
97                 }
98                 if (jObject.get(JSONApiResponseKeysEnum.CTRL_Y_MAX.getKey()) != null) {
99                     this.ctrlYmax = jObject.get(JSONApiResponseKeysEnum.CTRL_Y_MAX.getKey()).getAsFloat();
100                 }
101                 if (jObject.get(JSONApiResponseKeysEnum.CTRL_KEEP_FLOOR_WARM.getKey()) != null) {
102                     this.ctrlKeepFloorWarm = jObject.get(JSONApiResponseKeysEnum.CTRL_KEEP_FLOOR_WARM.getKey())
103                             .getAsBoolean();
104                 }
105                 if (jObject.get(JSONApiResponseKeysEnum.CTRL_ANTI_WIND_UP.getKey()) != null) {
106                     this.ctrlAntiWindUp = jObject.get(JSONApiResponseKeysEnum.CTRL_ANTI_WIND_UP.getKey())
107                             .getAsBoolean();
108                 }
109             }
110             if (controlMode == 2) {
111                 if (jObject.get(JSONApiResponseKeysEnum.REFERENCE_ZONE.getKey()) != null) {
112                     this.referenceZone = jObject.get(JSONApiResponseKeysEnum.REFERENCE_ZONE.getKey()).getAsInt();
113                 }
114                 if (jObject.get(JSONApiResponseKeysEnum.CTRL_OFFSET.getKey()) != null) {
115                     this.ctrlOffset = jObject.get(JSONApiResponseKeysEnum.CTRL_OFFSET.getKey()).getAsFloat();
116                 }
117             }
118         }
119     }
120
121     /**
122      * Returns the refenceZone, if control-mode is {@link ControlModes#ZONE_FOLLOWER}, otherwise null.
123      *
124      * @return the referenceZone
125      */
126     public Integer getReferenceZone() {
127         return referenceZone;
128     }
129
130     /**
131      * Returns the ctrlOffset, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
132      *
133      * @return the ctrlOffset
134      */
135     public Float getCtrlOffset() {
136         return ctrlOffset;
137     }
138
139     /**
140      * Returns the manualValue, if control-mode is {@link ControlModes#MANUAL}, otherwise null.
141      *
142      * @return the manualValue
143      */
144     public Float getManualValue() {
145         return manualValue;
146     }
147
148     /**
149      * Returns the emergencyValue, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
150      *
151      * @return the emergencyValue
152      */
153     public Float getEmergencyValue() {
154         return emergencyValue;
155     }
156
157     /**
158      * Returns the ctrlKp, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
159      *
160      * @return the ctrlKp
161      */
162     public Float getCtrlKp() {
163         return ctrlKp;
164     }
165
166     /**
167      * Returns the ctrlTs, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
168      *
169      * @return the ctrlTs
170      */
171     public Float getCtrlTs() {
172         return ctrlTs;
173     }
174
175     /**
176      * Returns the ctrlTi, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
177      *
178      * @return the ctrlTi
179      */
180     public Float getCtrlTi() {
181         return ctrlTi;
182     }
183
184     /**
185      * Returns the ctrlKd, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
186      *
187      * @return the ctrlKd
188      */
189     public Float getCtrlKd() {
190         return ctrlKd;
191     }
192
193     /**
194      * Returns the ctrlImin, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
195      *
196      * @return the ctrlImin
197      */
198     public Float getCtrlImin() {
199         return ctrlImin;
200     }
201
202     /**
203      * Returns the ctrlImax, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
204      *
205      * @return the ctrlImax
206      */
207     public Float getCtrlImax() {
208         return ctrlImax;
209     }
210
211     /**
212      * Returns the ctrlYmin, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
213      *
214      * @return the ctrlYmin
215      */
216     public Float getCtrlYmin() {
217         return ctrlYmin;
218     }
219
220     /**
221      * Returns the ctrlYmax, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
222      *
223      * @return the ctrlYmax
224      */
225     public Float getCtrlYmax() {
226         return ctrlYmax;
227     }
228
229     /**
230      * Returns the ctrlAntiWindUp, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
231      *
232      * @return the ctrlAntiWindUp
233      */
234     public Boolean getCtrlAntiWindUp() {
235         return ctrlAntiWindUp;
236     }
237
238     /**
239      * Returns the ctrlKeepFloorWarm, if control-mode is {@link ControlModes#PID_CONTROL}, otherwise null.
240      *
241      * @return the ctrlKeepFloorWarm
242      */
243     public Boolean getCtrlKeepFloorWarm() {
244         return ctrlKeepFloorWarm;
245     }
246
247     /*
248      * (non-Javadoc)
249      *
250      * @see java.lang.Object#toString()
251      */
252     @Override
253     public String toString() {
254         return "TemperatureControlConfig [referenceZone=" + referenceZone + ", ctrlOffset=" + ctrlOffset
255                 + ", manualValue=" + manualValue + ", emergencyValue=" + emergencyValue + ", ctrlKp=" + ctrlKp
256                 + ", ctrlTs=" + ctrlTs + ", ctrlTi=" + ctrlTi + ", ctrlKd=" + ctrlKd + ", ctrlImin=" + ctrlImin
257                 + ", ctrlImax=" + ctrlImax + ", ctrlYmin=" + ctrlYmin + ", ctrlYmax=" + ctrlYmax + ", ctrlAntiWindUp="
258                 + ctrlAntiWindUp + ", ctrlKeepFloorWarm=" + ctrlKeepFloorWarm + "]";
259     }
260 }