2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
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
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.digitalstrom.internal.lib.climate.jsonresponsecontainer.impl;
15 import org.openhab.binding.digitalstrom.internal.lib.climate.jsonresponsecontainer.BaseTemperatureControl;
16 import org.openhab.binding.digitalstrom.internal.lib.serverconnection.constants.JSONApiResponseKeysEnum;
18 import com.google.gson.JsonObject;
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.
25 * @author Michael Ochel - Initial contribution
26 * @author Matthias Siegele - Initial contribution
28 public class TemperatureControlConfig extends BaseTemperatureControl {
30 private Integer referenceZone;
31 private Float ctrlOffset;
32 private Float manualValue;
33 private Float emergencyValue;
38 private Float ctrlImin;
39 private Float ctrlImax;
40 private Float ctrlYmin;
41 private Float ctrlYmax;
42 private Boolean ctrlAntiWindUp;
43 private Boolean ctrlKeepFloorWarm;
46 * Creates a new {@link TemperatureControlConfig} through the {@link JsonObject} which will be returned by an
49 * @param jObject must not be null
51 public TemperatureControlConfig(JsonObject jObject) {
57 * Creates a new {@link TemperatureControlConfig} through the {@link JsonObject} which will be returned by a zone
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.
62 * @param jObject must not be null
63 * @param zoneID must not be null
64 * @param zoneName can be null
66 public TemperatureControlConfig(JsonObject jObject, Integer zoneID, String zoneName) {
67 super(jObject, zoneID, zoneName);
71 private void init(JsonObject jObject) {
73 if (controlMode == 1) {
74 if (jObject.get(JSONApiResponseKeysEnum.EMERGENCY_VALUE.getKey()) != null) {
75 this.emergencyValue = jObject.get(JSONApiResponseKeysEnum.EMERGENCY_VALUE.getKey()).getAsFloat();
77 if (jObject.get(JSONApiResponseKeysEnum.CTRL_KP.getKey()) != null) {
78 this.ctrlKp = jObject.get(JSONApiResponseKeysEnum.CTRL_KP.getKey()).getAsFloat();
80 if (jObject.get(JSONApiResponseKeysEnum.CTRL_TS.getKey()) != null) {
81 this.ctrlTs = jObject.get(JSONApiResponseKeysEnum.CTRL_TS.getKey()).getAsFloat();
83 if (jObject.get(JSONApiResponseKeysEnum.CTRL_TI.getKey()) != null) {
84 this.ctrlTi = jObject.get(JSONApiResponseKeysEnum.CTRL_TI.getKey()).getAsFloat();
86 if (jObject.get(JSONApiResponseKeysEnum.CTRL_KD.getKey()) != null) {
87 this.ctrlKd = jObject.get(JSONApiResponseKeysEnum.CTRL_KD.getKey()).getAsFloat();
89 if (jObject.get(JSONApiResponseKeysEnum.CTRL_MIN.getKey()) != null) {
90 this.ctrlImin = jObject.get(JSONApiResponseKeysEnum.CTRL_MIN.getKey()).getAsFloat();
92 if (jObject.get(JSONApiResponseKeysEnum.CTRL_MAX.getKey()) != null) {
93 this.ctrlImax = jObject.get(JSONApiResponseKeysEnum.CTRL_MAX.getKey()).getAsFloat();
95 if (jObject.get(JSONApiResponseKeysEnum.CTRL_Y_MIN.getKey()) != null) {
96 this.ctrlYmin = jObject.get(JSONApiResponseKeysEnum.CTRL_Y_MIN.getKey()).getAsFloat();
98 if (jObject.get(JSONApiResponseKeysEnum.CTRL_Y_MAX.getKey()) != null) {
99 this.ctrlYmax = jObject.get(JSONApiResponseKeysEnum.CTRL_Y_MAX.getKey()).getAsFloat();
101 if (jObject.get(JSONApiResponseKeysEnum.CTRL_KEEP_FLOOR_WARM.getKey()) != null) {
102 this.ctrlKeepFloorWarm = jObject.get(JSONApiResponseKeysEnum.CTRL_KEEP_FLOOR_WARM.getKey())
105 if (jObject.get(JSONApiResponseKeysEnum.CTRL_ANTI_WIND_UP.getKey()) != null) {
106 this.ctrlAntiWindUp = jObject.get(JSONApiResponseKeysEnum.CTRL_ANTI_WIND_UP.getKey())
110 if (controlMode == 2) {
111 if (jObject.get(JSONApiResponseKeysEnum.REFERENCE_ZONE.getKey()) != null) {
112 this.referenceZone = jObject.get(JSONApiResponseKeysEnum.REFERENCE_ZONE.getKey()).getAsInt();
114 if (jObject.get(JSONApiResponseKeysEnum.CTRL_OFFSET.getKey()) != null) {
115 this.ctrlOffset = jObject.get(JSONApiResponseKeysEnum.CTRL_OFFSET.getKey()).getAsFloat();
122 * Returns the refenceZone, if control-mode is
123 * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#ZONE_FOLLOWER}, otherwise
126 * @return the referenceZone
128 public Integer getReferenceZone() {
129 return referenceZone;
133 * Returns the ctrlOffset, if control-mode is
134 * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
136 * @return the ctrlOffset
138 public Float getCtrlOffset() {
143 * Returns the manualValue, if control-mode is
144 * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#MANUAL}, otherwise null.
146 * @return the manualValue
148 public Float getManualValue() {
153 * Returns the emergencyValue, if control-mode is
154 * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
156 * @return the emergencyValue
158 public Float getEmergencyValue() {
159 return emergencyValue;
163 * Returns the ctrlKp, if control-mode is
164 * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
168 public Float getCtrlKp() {
173 * Returns the ctrlTs, if control-mode is
174 * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
178 public Float getCtrlTs() {
183 * Returns the ctrlTi, if control-mode is
184 * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
188 public Float getCtrlTi() {
193 * Returns the ctrlKd, if control-mode is
194 * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
198 public Float getCtrlKd() {
203 * Returns the ctrlImin, if control-mode is
204 * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
206 * @return the ctrlImin
208 public Float getCtrlImin() {
213 * Returns the ctrlImax, if control-mode is
214 * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
216 * @return the ctrlImax
218 public Float getCtrlImax() {
223 * Returns the ctrlYmin, if control-mode is
224 * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
226 * @return the ctrlYmin
228 public Float getCtrlYmin() {
233 * Returns the ctrlYmax, if control-mode is
234 * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
236 * @return the ctrlYmax
238 public Float getCtrlYmax() {
243 * Returns the ctrlAntiWindUp, if control-mode is
244 * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
246 * @return the ctrlAntiWindUp
248 public Boolean getCtrlAntiWindUp() {
249 return ctrlAntiWindUp;
253 * Returns the ctrlKeepFloorWarm, if control-mode is
254 * {@link org.openhab.binding.digitalstrom.internal.lib.climate.constants.ControlModes#PID_CONTROL}, otherwise null.
256 * @return the ctrlKeepFloorWarm
258 public Boolean getCtrlKeepFloorWarm() {
259 return ctrlKeepFloorWarm;
265 * @see java.lang.Object#toString()
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 + "]";