]> git.basschouten.com Git - openhab-addons.git/blob
ac13d2bda90f9f2167bc8b4d6e46cc6aa5eb7b6f
[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
123      * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#ZONE_FOLLOWER}, otherwise
124      * null.
125      *
126      * @return the referenceZone
127      */
128     public Integer getReferenceZone() {
129         return referenceZone;
130     }
131
132     /**
133      * Returns the ctrlOffset, if control-mode is
134      * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
135      *
136      * @return the ctrlOffset
137      */
138     public Float getCtrlOffset() {
139         return ctrlOffset;
140     }
141
142     /**
143      * Returns the manualValue, if control-mode is
144      * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#MANUAL}, otherwise null.
145      *
146      * @return the manualValue
147      */
148     public Float getManualValue() {
149         return manualValue;
150     }
151
152     /**
153      * Returns the emergencyValue, if control-mode is
154      * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
155      *
156      * @return the emergencyValue
157      */
158     public Float getEmergencyValue() {
159         return emergencyValue;
160     }
161
162     /**
163      * Returns the ctrlKp, if control-mode is
164      * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
165      *
166      * @return the ctrlKp
167      */
168     public Float getCtrlKp() {
169         return ctrlKp;
170     }
171
172     /**
173      * Returns the ctrlTs, if control-mode is
174      * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
175      *
176      * @return the ctrlTs
177      */
178     public Float getCtrlTs() {
179         return ctrlTs;
180     }
181
182     /**
183      * Returns the ctrlTi, if control-mode is
184      * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
185      *
186      * @return the ctrlTi
187      */
188     public Float getCtrlTi() {
189         return ctrlTi;
190     }
191
192     /**
193      * Returns the ctrlKd, if control-mode is
194      * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
195      *
196      * @return the ctrlKd
197      */
198     public Float getCtrlKd() {
199         return ctrlKd;
200     }
201
202     /**
203      * Returns the ctrlImin, if control-mode is
204      * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
205      *
206      * @return the ctrlImin
207      */
208     public Float getCtrlImin() {
209         return ctrlImin;
210     }
211
212     /**
213      * Returns the ctrlImax, if control-mode is
214      * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
215      *
216      * @return the ctrlImax
217      */
218     public Float getCtrlImax() {
219         return ctrlImax;
220     }
221
222     /**
223      * Returns the ctrlYmin, if control-mode is
224      * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
225      *
226      * @return the ctrlYmin
227      */
228     public Float getCtrlYmin() {
229         return ctrlYmin;
230     }
231
232     /**
233      * Returns the ctrlYmax, if control-mode is
234      * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
235      *
236      * @return the ctrlYmax
237      */
238     public Float getCtrlYmax() {
239         return ctrlYmax;
240     }
241
242     /**
243      * Returns the ctrlAntiWindUp, if control-mode is
244      * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
245      *
246      * @return the ctrlAntiWindUp
247      */
248     public Boolean getCtrlAntiWindUp() {
249         return ctrlAntiWindUp;
250     }
251
252     /**
253      * Returns the ctrlKeepFloorWarm, if control-mode is
254      * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
255      *
256      * @return the ctrlKeepFloorWarm
257      */
258     public Boolean getCtrlKeepFloorWarm() {
259         return ctrlKeepFloorWarm;
260     }
261
262     /*
263      * (non-Javadoc)
264      *
265      * @see java.lang.Object#toString()
266      */
267     @Override
268     public String toString() {
269         return "TemperatureControlConfig [referenceZone=" + referenceZone + ", ctrlOffset=" + ctrlOffset
270                 + ", manualValue=" + manualValue + ", emergencyValue=" + emergencyValue + ", ctrlKp=" + ctrlKp
271                 + ", ctrlTs=" + ctrlTs + ", ctrlTi=" + ctrlTi + ", ctrlKd=" + ctrlKd + ", ctrlImin=" + ctrlImin
272                 + ", ctrlImax=" + ctrlImax + ", ctrlYmin=" + ctrlYmin + ", ctrlYmax=" + ctrlYmax + ", ctrlAntiWindUp="
273                 + ctrlAntiWindUp + ", ctrlKeepFloorWarm=" + ctrlKeepFloorWarm + "]";
274     }
275 }